Why won't my plot appear on the graph?

1 visualización (últimos 30 días)
Lillian Turner
Lillian Turner el 11 de Feb. de 2020
Respondida: Star Strider el 11 de Feb. de 2020
Hello
I am currently trying to plot a function, but the line does not appear on the graph. When I display the x and y values, everything is being computer correctly, but it will not appear on the graph. My code is below:
figure;
for i = 0: 360
a = 10;
w1 = 360;
t1 = i;
t2 = atan((tan(t1))/(cos(a)));
num = w1*sec(t1).^2;
den = sec(t2).^2*cos(a);
w2 = num./den;
display (i);
display (w2);
plot (t1, w2, 'b-','LineWidth', 3);
hold on;
end
Thank You!

Respuesta aceptada

Star Strider
Star Strider el 11 de Feb. de 2020
It can, however since you are plotting points rather than lines, you must use a marker.
Change the plot call to:
plot (t1, w2, 'b.','LineWidth', 3);
and the dots magickally appear!
If you want to plot a line, this works:
for i = 0: 360
a = 10;
w1 = 360;
t1 = i;
t2 = atan((tan(t1))/(cos(a)));
num = w1*sec(t1).^2;
den = sec(t2).^2*cos(a);
w2(i+1,:) = num./den;
t1v(i+1) = t1;
end
figure
plot (t1v, w2, 'b-','LineWidth', 3);
There are of course much more efficient ways to do this.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by