Why Matlab does not plot "for loop" generated vector?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anne
am 16 Feb. 2020
Kommentiert: Walter Roberson
am 19 Feb. 2020
I am quite a beginner and after hours of googling I just could not figure out why Matlab does not plot what needed. I can see only a blank.
My script is:
c = 7;
n=12;
for i = 0:1:n
u=i;
p_u = (2.3/c)*((u/c)^1.3)*exp(-(u/c)^2.3);
hours =8760*p_u*(1-0.09);
hold on;
plot(u, hours)
end
Thank you in advance!
0 Kommentare
Akzeptierte Antwort
David Hill
am 16 Feb. 2020
Best to use arrays/vectors.
c=7;
n=12;
u=0:.1:n;
hours = (2.3/c)*((u/c).^1.3).*exp(-(u/c).^2.3)*(1-0.09)*8760;
plot(u,hours)
4 Kommentare
Rik
am 18 Feb. 2020
You can define u however you like. That is the benefit of writing code like this.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!