No lines on graph
8 次查看(过去 30 天)
显示 更早的评论
Hi
I try to plot this function but I can't. There is no lines on the graph. Anybody knows whats wrong with it?
Thanks
for x1=0:alphaL;
Mb1varde=feval(f1,x1);
for Z=0.698:-0.698
Y1= feval(Bojspanning,Z);
plot(Z,Y1,'-') ;
hold on
end
end
0 个评论
回答(3 个)
Walter Roberson
2016-10-7
For plot() the default marker is 'none'. When you plot only one point at a time, because there are no second points to connect to, only a single marker would be plotted. But the default marker is 'none', so no line gets plotted (nothing to connect to) and no marker gets plotted (because of the default.)
You cannot get lines by plotting one point at a time. You can get a point plot, if you tell it to use a non-default marker.
You could go in afterwards and find all those point plots and extract the coordinates and connect them, but much better is to not plot at each step and instead record the x and y coordinates in vectors, and then plot the entire vectors afterwards.
1 个评论
Walter Roberson
2016-10-7
Zvals = 0.698:-0.698;
for Zidx = 1 : length(Zvals)
Z = Zvals(Zidx);
...
Y1(Zidx) = ...
end
plot(Zvals, Y1)
However, notice that 0.698:-0.698 is the empty vector. When the initial value is greater than the final value and the step is positive (which is the default) then the resulting vector is empty. You could switch to -0.698:0.698 which would not be empty, but the default step size is 1 so the result would have only 2 entries, -0.698 and 1-0.698 as 2-0.698 would be past the end point 0.698 . Consider using linspace()
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!