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

21 ビュー (過去 30 日間)
Natasha D
Natasha D 2019 年 3 月 7 日
コメント済み: Walter Roberson 2021 年 1 月 22 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 3 月 9 日
Perhaps
pcolor(x, y, data)
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 Center および File ExchangeAnnotations についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by