how do i plot a graph after a for loop
Mostra commenti meno recenti
so for my assignment i have to plot a graph for deflection angle by angle of attack, however the values for the deflection angle have been calculated using a for loop cycle. how do i plot the results as a single graph?
3 Commenti
Dyuman Joshi
il 25 Ott 2023
Modificato: Dyuman Joshi
il 25 Ott 2023
Store the values in an array and then plot the array.
Depending upon the operations performed in the for loop, you migth be able to vectorize your code as well.
denzel sibanda
il 25 Ott 2023
Dyuman Joshi
il 25 Ott 2023
%% Example
for k=1:number_of_iterations
%do some calculations
%store the value
deflection_angle(k) = value_from_calculation;
end
Risposte (2)
Save the deflection angles in an array and plot after the for-loop.
Star Strider
il 25 Ott 2023
0 voti
Subscript the variables-of-interest in the loop according to the loop index counter values, and then plot those variables after the loop terminates. They should be vectors and should plot correctly.
Example —
for k = 1:10
x(k) = cos(k);
y(k) = sin(k);
end
figure
plot(x, y)
grid
.
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!