how, using a for loop, can I create an array
Ältere Kommentare anzeigen
I am trying to create an array for V and A that can then be plotted.
for a = [.25:.25:4] %innder radius
b = a+2 ;%outer radius
V = (.25*pi^2).*(a+b)*(b-a).^2 %equation for Volume
A = pi^2*(b^2-a.^2) %equation for Area
end
plot(V,A) %plot Volume vs. Area
with the current code, when I run the script, V and A only have one value which is equal to using a = 4
but I want every value to be saved, not just the last value for V and A
Akzeptierte Antwort
Weitere Antworten (1)
David Hill
am 7 Dez. 2020
Bearbeitet: David Hill
am 7 Dez. 2020
No loop needed.
a=.25:.25:4;
b=a+2;
V=(.25*pi^2).*(a+b).*(b-a).^2;
A=pi^2*(b.^2-a.^2);
plot(V,A);
1 Kommentar
George Amor
am 7 Dez. 2020
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!