plot from while loop
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Jan
2012-9-23
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 个评论
Azzi Abdelmalek
2012-9-23
编辑:Azzi Abdelmalek
2012-9-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!