Plotting within 0 to 360

20 次查看(过去 30 天)
Sarah Kneer
Sarah Kneer 2021-1-7
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 个评论
Image Analyst
Image Analyst 2021-1-7
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 2021-1-7
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.

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2021-1-7
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

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by