Create surf (3D plot) with axis limitation from 2D matrix - animated

3 ビュー (過去 30 日間)
Jack Daniels
Jack Daniels 2022 年 11 月 11 日
コメント済み: Jack Daniels 2022 年 11 月 14 日
I am trying to create "mesh" (surf) out of 2D matrix which is changing by time on its values
x = 1:30;
y = x;
Z = [ 1 1 1; 1 1 1; 1 1 1];
[X30 , Y30] = meshgrid(x,y);
a=1;
for inc = 1:30
Z30 = imresize (Z,[30 30],'bicubic');
a = a + 1;
Z(2,2) = a;
surf(X30,Y30,Z30)
axis([0 30 0 30 0 30])
pause(0.5)
end
The "surf" shows plot with "auto" axis limitation and after applying "axis" function are the size limited, so I have two plots refreshed subsequently - can be set the axis of surf once?

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 11 月 13 日
編集済み: Cris LaPierre 2022 年 11 月 13 日
Each time you call the surf function, you get a brand new axes. This means any settings set in the previous axes are lost, and must be reset.
It looks like you just want to update the Z values of your surface. You can do that by accessing the ZData property of your plot. Try this.
x = 1:30;
[X30 , Y30] = meshgrid(x);
Z = [ 1 1 1; 1 1 1; 1 1 1];
Z30 = imresize (Z,[30 30],'bicubic');
sf = surf(X30,Y30,Z30);
axis([0 30 0 30 0 30])
for a = 1:30
Z(2,2) = a;
Z30 = imresize (Z,[30 30],'bicubic');
sf.ZData = Z30;
pause(0.5)
end
  5 件のコメント
Cris LaPierre
Cris LaPierre 2022 年 11 月 14 日
Look into the options available in the axis command, in particular the 'style' options.
I don't understand the rest of yoru questions, but they appear to be more about app designer, so I would suggest starting a new question for that.
Jack Daniels
Jack Daniels 2022 年 11 月 14 日
That's correct. It's about the AppDesigner.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by