plot from while loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Jan
le 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 commentaires
Azzi Abdelmalek
le 23 Sep 2012
Modifié(e) : Azzi Abdelmalek
le 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 commentaires
Voir également
Catégories
En savoir plus sur Annotations 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!