Problem with array Input

1 次查看(过去 30 天)
KAPIL MAMTANI
KAPIL MAMTANI 2015-11-6
Earlier I was assigning scalar values to C2 N2 P2 and the code was running perfectly.But I want to check the code for various random value of these three.Let me tell you ....for example I`ve created a 1x1000 array of these three, now i want to run my loop for full length of t,for Ist set of these three variables and store the results,then run go on running till 1000 sets of these three.Then I will plot them and analyz result.This what i intend to do .Please help me on how to do it...I have posted an image..

回答(1 个)

Image Analyst
Image Analyst 2015-11-6
What is t? The column index? What do you mean by "store"? They're already stored. You stored x in C2, and y in N2, and z in P2 (not sure why the names don't match though, like why C2 is x1,x2,x3... instead of c1,c2,c3,...). Anyway, you can send those to your function -- go ahead and plot them if you want - just call plot().
for col = 1 : length(C2)
result(col) = MyFunction(C2(col), N2(col), P2(col));
end
% Now you have the results.
% Plot the results if you want
plot(result, 'b*-');
grid on;
% Save figure if you want
export_fig(......
  2 个评论
KAPIL MAMTANI
KAPIL MAMTANI 2015-11-6
Thanks for responding MISTER. I am sorry for not posting my script. In image posted ,i wanted to say that N2 C2 P2 are input to a loop and earlier i was taking them as fixed values but now I intend to randomize them and use in loop, but it is giving me error.These three are not necessarily 1x1000 size.Also every time loop is using there specific set of values I want to save result in form of graph as scripted in loop.
Image Analyst
Image Analyst 2015-11-6
Do you just want to pull the plot() inside the loop? If so, you'll need a drawnow after it
for k = 1 : length(t) - 1
% code....
plot(.......
drawnow;
end

请先登录,再进行评论。

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by