How to change interval of normalized x-axis?

5 ビュー (過去 30 日間)
Jemimah Dizon
Jemimah Dizon 2022 年 6 月 12 日
編集済み: dpb 2022 年 6 月 12 日
Hello,
I am plotting a graph where the values for x-axis is normalized into 1-100%. For example, I have 157 data points (variable, may change each graph) for the x axis. The 0% of this will be the 1st data point and the 100% of this will be the 157th data point.
So far I have this code:
plot(x,y);
xt=xticks;
normalizedX=normalize(xt,'range',[0 100]);
xticklabels(normalizedX);
And it produces this:
This example has 132 data points for x-axis, and it successfully normalized it into 1-100%. However, I want the interval and label of the x-axis to be in 10s. So, the label is '10%, 20%, .... 100%'.
Thanks!

採用された回答

dpb
dpb 2022 年 6 月 12 日
編集済み: dpb 2022 年 6 月 12 日
normalize() and plot against the x variable itself instead of the "prettified" xtick values.
plot(normalize(x,'range',[0 100]),y);
and the prettifier will find the 10s tick values for you automagically.
  1 件のコメント
Jemimah Dizon
Jemimah Dizon 2022 年 6 月 12 日
Thanks, this worked nicely!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by