Problem with array Input
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Image Analyst
le 6 Nov 2015
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 commentaires
Image Analyst
le 6 Nov 2015
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
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!