フィルターのクリア

Creating a custom axis

31 ビュー (過去 30 日間)
John Carroll
John Carroll 2022 年 10 月 31 日
コメント済み: Voss 2022 年 11 月 1 日
I am looking to create a custom x axis for a 3D surface plot. My x data has a form similar to V = [0 5 10 15 20 15 10 5 0 -5 -10 -15 -20 -15 -10 -5 0]. Each point will have a corrosponding y and z point. When I plot them how ever the similar x points overlap since they have the same value. I would like to make the x axis use the values in the matrix without overlap but instead writing them in the order they appear in the matrix. If possible I'd like to preserve the numerical value without converting to text.
Currently I create a variable for the x axis V similar to above. In the surafce plat I Use V instead of T as I show below. But this causes one have of the data to be graphed over the other half. I then created a linear matrix of datat points from 1 to 161 and used that at the x axis. This works and I get the graph I am looking for however the x axis label is wrong. I would like to force the axis to use V. To do this I tried to convert to a string and label the x axis with it. QualityFactor is a matrix of size 200x161 and FreqS is of size 200x1. When I graph this I get the following
The graph axis forces itself to 200 points along the x axis. To correct this I force the axis to 161 to match the size of the data and I get the following
In the first case I get the axis I want but the data is compressed and doesn't fill the axis. When I force the axis I get the size plot I want but the axis is cut off and doesn't rescale to match the data.
How might I fix this issue?
Thank you
VoltMax = 200;
VoltStep = 5;
VSD = VoltMax/VoltStep;
V = VoltStep*[0:VSD VSD-1:-1:-VSD -VSD+1:-1 0]; V will be a 1x161 matrix
T=1:1:161;
Vt=string(V);
surf(T, FreqS, QualityFactor)
xticklabels({Vt(1),Vt(41),Vt(81),Vt(121),Vt(161)})

採用された回答

Voss
Voss 2022 年 10 月 31 日
Set the xticks when you set the xticklabels (xticklabels by itself doesn't set the locations of the ticks, just their labels). And probably set the xlim as well.
VoltMax = 200;
VoltStep = 5;
VSD = VoltMax/VoltStep;
V = VoltStep*[0:VSD VSD-1:-1:-VSD -VSD+1:-1 0];
T=1:1:161;
surf(T, linspace(0,20,200), rand(200,161)) % random data for demo
xticks(T(1:VSD:end))
xticklabels(string(V(1:VSD:end)))
xlim(T([1 end]))
view(2)
  2 件のコメント
John Carroll
John Carroll 2022 年 10 月 31 日
This works perfectly thank you
Voss
Voss 2022 年 11 月 1 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by