plot from while loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, to be general, suppose i have written the following code
s=0
figure
while s<10
s=s+0.05
n= (µ-s)./nthroot((µ<s).*(s-µ),3)
plot (s,n)
end
when running, this code is giving me the values of n as points that corresponds to each value of s However, I want to get all the values of n in an array and then to plot them
Thank you to tell me how to modefy the previous code to do this
BEST REGARDS
[EDITED, Jan, code formatted]
0 Kommentare
Antworten (2)
Jan
am 23 Sep. 2012
figure
s = 0:0.05:10;
n = zeros(1, length(s));
for ii = 1:length(s)
n(ii) = (my - s(ii)) ./ nthroot((my < s(ii)) .* (s(ii) - my), 3);
end
plot(s,n);
0 Kommentare
Azzi Abdelmalek
am 23 Sep. 2012
Bearbeitet: Azzi Abdelmalek
am 23 Sep. 2012
close all
s=0;mu=0.5
figure
set(gca,'xlim',[0.5 10],'ylim',[-5 0])
while s<10
s=s+0.05
n= (mu-s)./nthroot((mu<s).*(s-mu),3)
hold on;plot (s,n,'*r');pause(0.05)
end
0 Kommentare
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!