Info
此问题已关闭。 请重新打开它进行编辑或回答。
Plotting using a for loop
2 次查看(过去 30 天)
显示 更早的评论
I'm having trouble with plotting a graph when using a for loop to generate the values.
x = 0: 0.1 : 1.4
for x = 0:0.1:1.4
y = iteration2shear(x)
end
plot(x,y)
hold on
The function I'm calling generates the correct values for each value of y, but im struggling to generate a plot to illustrate it.
0 个评论
回答(2 个)
Rik
2020-10-26
You are forgetting to index your y variable. In general it is easier to write your code like this in such cases:
x = 0: 0.1 : 1.4;
y=zeros(size(x));
for n=1:numel(x)
y(n) = iteration2shear(x);
end
plot(x,y)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!