No lines on graph

조회 수: 6 (최근 30일)
Shahab kohdami
Shahab kohdami 2016년 10월 7일
편집: Walter Roberson 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