Plotting using x-axis arrays that are not in monotonically increasing order?

22 次查看(过去 30 天)
My goal is to plot a curtain profile using imagesc() with the x-axis corresponding to the Latitude values and y-axis to the Altitude. My x-axis data are the latitude points of an instrument orbiting the Earth. In this scenario, the latitude values increase (reaching top of orbit) and then they decrease.
I've been able to successfully plot these profiles for when the latitude values were in increasing/decreasing order but not when they have both scenarious occuring.
Anyone have an idea/code that can fix this error? Thank you!
x = latitude;
y = altitude;
z = data; % (in matrix format)
imagesc(x, y, z)
%Error: x vector must be in increasing order%
  3 个评论
Natasha D
Natasha D 2019-3-11
Unfortunately the data exceeds the upload size.
I tried pcolor but it isn't giving me what I want it to. Thank you though.

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2019-3-9
编辑:Cris LaPierre 2019-3-20
Is your x vector evenly sampled? Without having actual data, my suggestion would be make x=1:length(latitude) and plot that. Then update your xTickLabels to be the actual latitude values.
  3 个评论
Cris LaPierre
Cris LaPierre 2021-1-22
The underlying ruler is going to be evenly spaced and monotonically increasing. This is what is used to place your X and Y values.
Imagesc is slightly different in that it uses the row indices as the Y values, and the column indices as the X values. If you want to change the 'direction', you must manipulate the matrix. Perhaps try using fliplr to reverse the x direction, of flipud to revers the y direction.
Walter Roberson
Walter Roberson 2021-1-22
You would not typically need to fliplr or flipud for imagesc. However you might want to
set(gca, 'YDir', 'normal')
The default for imagesc() is YDir reverse, so that data in the low Y indices (lower row) is shown at the top of the display and higher Y indices (higher row) is at the bottom of the display.

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by