Plotting within 0 to 360

29 views (last 30 days)
Sarah Kneer
Sarah Kneer on 7 Jan 2021
Commented: Sarah Kneer on 7 Jan 2021
I need to have a plot between 0 and 360 using my data, and as the values should be the same I did the following:
i = 0:1:360;
for i = 1:1:length(i)
if beta_1 < 0
beta_1 = beta_1 + 360;
end
if beta < 0
beta = beta + 360;
end
plot(beta_1, alpha_1,':r')
title ('Elevation and Azimath Angles of Day 1 and Day 182')
xlabel ('Azimuth Angle (degrees Celsius)')
ylabel ('Elevation Angle (degrees Celsius)')
hold on
plot(beta, alpha, ':k')
legend ('Day 1', 'Day 182')
ylim([0 70])
hold off
end
but it looks like the values are not going being added by 360
  4 Comments
Image Analyst
Image Analyst on 7 Jan 2021
Please attach them so we can use them.
save('answers.mat', 'beta', 'beta_1', 'alpha', 'alpha_1');
then use the paper clip icon.
When you do this:
if beta_1 < 0
beta_1 = beta_1 + 360;
end
if beta < 0
beta = beta + 360;
end
how does any of that depend on the iteration? Nothing changes so it's the same with every iteration. Are they a scalar, or an vector?
Did yoiu perhaps mean this:
if beta_1(i) < 0
beta_1(i) = beta_1(i) + 360;
end
so that the beta_1 value changes during each iteration?
Sarah Kneer
Sarah Kneer on 7 Jan 2021
Okay, I think I understand what you mean, I just did the last bit that you suggested:
if beta_1(i) < 0
beta_1(i) = beta_1(i) + 360;
end
(for beta as well) and the plot just came out the right way, thank you very much.

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 7 Jan 2021
You're plotting individual points as separate lines, so they're not connected and the default marker is 'none'.
h = plot(1, 1);
h.Marker
ans = 'none'
If you want to do this, either create vectors of data and plot those vectors after the loop or create an animatedline and addpoints to that animatedline in the loop.
Vectors of data:
x = zeros(1, 10);
y = zeros(1, 10);
for k = 1:10
x(k) = k;
y(k) = k.^2;
end
plot(x, y, ':k')
Animated line:
figure
h = animatedline('Color', 'r', 'LineStyle', '--');
for k = 1:10
addpoints(h, k, k.^2);
end
  1 Comment
Sarah Kneer
Sarah Kneer on 7 Jan 2021
Okay thank you very much, I appreciate that

Sign in to comment.

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!