Reseting and refresing figure with tiledlayout/nexttitle
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jack Daniels
el 17 de Nov. de 2022
Comentada: Jack Daniels
el 17 de Nov. de 2022
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?
0 comentarios
Respuesta aceptada
Matt J
el 17 de Nov. de 2022
Editada: Matt J
el 17 de Nov. de 2022
One possibility:
A(2,2)=60;
mtrx_surf(A)
A(2,2)=30;
mtrx_surf(A)
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!