Plot with x-axis limits going from [180:360] then [0:180] contiguously

15 次查看(过去 30 天)
Here is a sample plot of my data:
I've searched through the community looking for ideas but I may be struggling with how to search for this particular issue.
I've come across several cases that would solve my issue "visually" using "unwrap" or "wrapTo360", but these both would alter my data set.
I want to keep the integrity of my data, but I'd like to have my plot be contigous from 250 degrees at the origin to 360 degrees, then continue to 0 degrees to 250 degrees similar to the second sample plot. (I've set the summary to be 180:360 to aid others searching as those are typical angles and mine are more specific).
I would like to do this programmatically as I am able to do it manually, but I have thousands of these to run through.
  2 个评论
the cyclist
the cyclist 2023-6-15
It's difficult to infer the fully general "rule" here, from just one example. Can you post two or three examples of the data? You can upload it using the paper clip icon in the INSERT section of the toolbar.
em7
em7 2023-6-15
@the cyclist Sure! It's just made up data as I'm unable to post the actual data for work reasons. But It's the same idea; I've attached my sample data set.
It's essentially set of Elevation vs Azimuth data where the elevation ranges from 0 to 80 degrees incrementally and the azimuth corresponds to each elevation increment starting at 250 degrees, but wraps at 360 degrees.

请先登录,再进行评论。

回答(2 个)

Les Beckham
Les Beckham 2023-6-15
It seems extremely odd that your data would "wrap" at 250 degrees. Nevertheless...
elevation = [26:80 0:25];
azimuth = linspace(0, 360, numel(elevation));
delta_az = unique(diff(azimuth));
plot(azimuth, elevation, '.')
grid on
xlabel('Azimuth (deg)')
ylabel('Elevation (deg)')
idx = azimuth >= 250;
figure
offset = azimuth(find(azimuth <= 250, 1, 'last'));
plot([azimuth(idx) (azimuth(~idx) + 360 + delta_az)] - offset, [elevation(idx) elevation(~idx)], '.')
grid on
xticklabels(string([250:50:350 0:50:250]))
xlabel('Azimuth (deg)')
ylabel('Elevation (deg)')

the cyclist
the cyclist 2023-6-15
You only give one example, and this will do what you want for this one example. It does not touch your data, just what is plotted.
I am guessing this is not robust enough for your data in general. But, since you have not given us more examples, it is not possible to know how general this needs to be.
Maybe you can figure out the rest. (Also, I notice a couple rogue points. I did not inspect the reason for those.)
tbl = readtable("sampleData.xlsx");
figure
scatter(tbl.Var1 + 360*(tbl.Var1<250),tbl.Var2)
set(gca,"XTickLabel",[250:50:350 0:50:360])

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by