Addressing arrays between functions
Show older comments
I'm running a while loop and i need to use a value generated within the loop to provide a different variable from a different script and i'm having trouble getting the generated variable into the other functions. Here's what i have, if anyone has any ideas it'd be greatly appreciated.
function R_New = R_New (theta, phi, Params, LaserParams, Orientation)
run_number = 1;
Conv{1} = 0;
while Conv{run_number} == 0
R_initial = Params(1);
R_1{run_number} = R_dash(theta, phi, Params, LaserParams, run_number,Orientation);
Radius = R_Sphere(theta, phi, Params, LaserParams, run_number, Orientation);
R_2{run_number} = R_1{run_number}.*(R_initial/Radius);
Conv{run_number} = Convergence(theta, phi, Params, LaserParams, run_number, Orientation);
run_number = run_number +1;
end
Where R_2 is the generated variable, used in the 2nd iteration of the loop in function R_dash.
Here is R_dash
function R_dash = R_dash(theta, phi, Params, LaserParams, run_number, Orientation, R_2)
I just dont know how to get R_2 into the R_dash function so that i can access the precious values of it.
Thanks
if run_number == 1;
R = R_0(Params);
else
R = R_2{run_number};
end
Pert = P(theta, phi, Params, LaserParams, run_number, Orientation);
R_dash = R + Pert;
1 Comment
Jan
on 6 May 2012
Are you working with Dougie, who has asked a very similar question? Or do you use multiple accounts? See: http://www.mathworks.de/matlabcentral/answers/37341-for-loop
Please format your code and explain, what the code fragment after "Thanks" means.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!