Plots using for loops
1 次查看(过去 30 天)
显示 更早的评论
This is my text, i want do a loglog plot for error which is my function Ptoject_example3 against h, but wheneber I run the code doesnt plot anything.
m=1;
for h=0.01:0.01:0.1
error = Project_example3(h,m);
end
h=0.01:0.01:0.1;
figure;
loglog(error,h)
0 个评论
采纳的回答
KSSV
2022-6-10
编辑:KSSV
2022-6-10
Your code saves, only one value for error, which happens to be the last value of the loop. You need to save error into an array and then plot.
m=1;
h=0.01:0.01:0.1;
error = zeros(size(h)) ;
for i = 1:length(h)
error(i) = Project_example3(h(i),m);
end
figure;
loglog(error,h)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!