No lines on graph
8 views (last 30 days)
Show older comments
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 Comments
Answers (3)
Walter Roberson
on 7 Oct 2016
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 Comment
Walter Roberson
on 7 Oct 2016
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()
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!