How to make an axis that goes up and down?

8 ビュー (過去 30 日間)
Camilo Garcia
Camilo Garcia 2022 年 6 月 6 日
コメント済み: Star Strider 2022 年 6 月 9 日
I have a surf plot and I need one of the axis to do from 0 to 1 and then back to 0. Because I am plotting some data against the voltage of a triangle waveform. Is there a way to do this in matlab?
Like the y axis in the attached image that goes from -0.4 to 1.3 to -0.4.
Thank you in advance and have a nice day.

採用された回答

Star Strider
Star Strider 2022 年 6 月 6 日
The tick values must be monotonically increasing or decreasing. The tick labels can be whatever you want.
x = 0:15;
y = -0.4:0.1:0.4;
z = repmat([y(1:5) flip(y(1:4))], numel(x), 1)';
figure
surf(x, y, z)
set(gca, 'YTick',[-0.4 0 0.4], 'YTickLabel', [-0.4 1.3 -0.4])
view(0,90)
xlabel('X')
ylabel('Y')
.
  2 件のコメント
Camilo Garcia
Camilo Garcia 2022 年 6 月 9 日
Thank you, this worked as I wanted. Have a nice day.
Star Strider
Star Strider 2022 年 6 月 9 日
As always, my pleasure!
You, too!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by