Problem with array Input
1 次查看(过去 30 天)
显示 更早的评论
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..
0 个评论
回答(1 个)
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 个评论
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!