How can I plot a reverse x-axis on the same graph?

I have x = [0 1 2 3 4 3 2 1 0]; and y = 2*x; how can I plot(x,y) and see the value on x-axis as [0 1 2 3 4 3 2 1 0]?

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 1 月 26 日
編集済み: KALYAN ACHARJYA 2022 年 1 月 26 日

0 投票

#Convert to strings
x=[0 1 2 3 4 3 2 1 0];
y = 2*x;
plot(y);
data=string(x);
set(gca,'xtick',1:length(x),'xticklabel',data)

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2022 年 1 月 26 日

編集済み:

2022 年 1 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by