Problem with array Input
이전 댓글 표시
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
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
2015년 11월 6일
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
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!