No lines on graph

8 visualizaciones (últimos 30 días)
Shahab kohdami
Shahab kohdami el 7 de Oct. de 2016
Editada: Walter Roberson el 7 de Oct. de 2016
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

Respuestas (3)

Massimo Zanetti
Massimo Zanetti el 7 de Oct. de 2016
You are plot just one point a time..

Walter Roberson
Walter Roberson el 7 de Oct. de 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 comentario
Walter Roberson
Walter Roberson el 7 de Oct. de 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()

Iniciar sesión para comentar.


Shahab kohdami
Shahab kohdami el 7 de Oct. de 2016
Editada: Walter Roberson el 7 de Oct. de 2016
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by