No lines on graph

8 次查看(过去 30 天)
Shahab kohdami
Shahab kohdami 2016-10-7
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

回答(3 个)

Massimo Zanetti
Massimo Zanetti 2016-10-7
You are plot just one point a time..

Walter Roberson
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
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()

请先登录,再进行评论。


Shahab kohdami
Shahab kohdami 2016-10-7
编辑:Walter Roberson 2016-10-7
Thank you for your answers
I just wonder how about the value of x? Because x is between 0:18 meter, a beam length. I am calculating the stress in a beam in every x position. For example in x=3 meter I want to calculate the stress, Y1= feval(Bojspanning,Z), in the beams web which is 698 mm from flange to flange! Z is lenght of beams web plus 2 flanges.

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by