フィルターのクリア

Reseting and refresing figure with tiledlayout/nexttitle

17 ビュー (過去 30 日間)
Jack Daniels
Jack Daniels 2022 年 11 月 17 日
コメント済み: Jack Daniels 2022 年 11 月 17 日
I am trying to plot and refresh the figure which I created with "tiledlayout"
function out = mtrx_surf(Z3)
persistent srf
if isempty(srf)
x = 1:30;
[X30, Y30] = meshgrid(x);
%Z30 = ones(30);
Z30 = imresize(Z3,[30 30],"bilinear")';
tiledlayout(1,2)
nexttile
srf = surf(X30,Y30,Z30);
axis([0 30 0 30 -5 80])
clim([20 60])
nexttile
srf = surf(X30,Y30,Z30);
shading interp
axis([0 30 0 30 -5 80])
clim([20 60])
else
Z30 = imresize(Z3,[30 30],"bilinear")';
% tiledlayout(1,2)
nexttile
srf.ZData = Z30;
axis([0 30 0 30 -5 80])
clim([20 60])
nexttile
srf.ZData = Z30;
shading interp
% axis([0 30 0 30 -5 80])
% clim([20 60])
%puase(0.5)
end
out = 1;
clear surf
end
It turns out that at very first step I am able to create plot with 2 tiles
on the next time as "else" is evaluted then it crashes ... and no plots.
How can I evalute, reset, refresh the same plot when using tiledlayout function to be able to plot multi-charts on the same figure? How can I optimized tehe my function?

採用された回答

Matt J
Matt J 2022 年 11 月 17 日
編集済み: Matt J 2022 年 11 月 17 日
One possibility:
A(2,2)=60;
mtrx_surf(A)
ans = 1
A(2,2)=30;
mtrx_surf(A)
ans = 1
function out = mtrx_surf(Z3)
persistent srf
if isempty(srf)
clear srf
x = 1:30;
[X30, Y30] = meshgrid(x);
%Z30 = ones(30);
Z30 = imresize(Z3,[30 30],"bilinear")';
tiledlayout(1,2)
nexttile
srf(1) = surf(X30,Y30,Z30);
axis([0 30 0 30 -5 80])
clim([20 60])
nexttile
srf(2) = surf(X30,Y30,Z30);
shading interp
axis([0 30 0 30 -5 80])
clim([20 60])
else
Z30 = imresize(Z3,[30 30],"bilinear")';
srf(1).ZData = Z30;
axis([0 30 0 30 -5 80])
clim([20 60])
nexttile
srf(2).ZData = Z30;
shading interp
end
out = 1;
end
  3 件のコメント
Matt J
Matt J 2022 年 11 月 17 日
I fixed it.
Jack Daniels
Jack Daniels 2022 年 11 月 17 日
Now, it wokrs, perfect!
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Design についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by