MATLAB Answers

Why won't my plot appear on the graph?

1 view (last 30 days)
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!

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 11 Feb 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.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags


Translated by