# How would one update the plotted data without resting the figure axes labels and other format elements?

1 ビュー (過去 30 日間)
Josh Ezekiel 2019 年 10 月 12 日
Answered: darova 2019 年 10 月 16 日
while t<=tf
for i=2:Nx
for j=2:Ny
T(i,j) =T(i,j)+dt*alpha*(((T(i-1,j)-2*T(i,j)+T(i+1,j))/dx^2)+((T(i,j-1)-2*T(i,j)+T(i,j+1))/dy^2));
history_T=cat(3,history_T,T);
end
end
t=t+dt;
X=[0:0.05:1];
Y=[0:0.05:1];
%% PLOT
surf(X,Y,T)
pause(0.01)
%% FORMATING ELEMENTS
xlabel('Width, \$m\$','Interpreter','Latex')
ylabel('Depth, \$m\$','Interpreter','Latex')
zlabel('Temperature, \$T\$','Interpreter','Latex')
xlim([0 Lx])
ylim([0 Ly])
zlim([0 100])
set (gca,'FontSize',10,'FontName','Times')
set(gcf,'color','w');
end
Where X and Y are row vectors and T is a matrix with dimensions (length(X),length(Y). T updated with every repitition of the while loop, producing a surf plot that changes accordingly.
The plot appears with default formatting until the final iteration where it formats it as I intend.
How can I instruct MATLAB to keep the formatting elements constant throught the iteration?
Many thanks.

#### 0 件のコメント

サインイン to comment.

### 件の回答 (2)

Divya Yerraguntla 2019 年 10 月 16 日
Hi Josh,
Try placing the pause(0.01) line of code after %% Formating elements section i.e. after the set(gcf,'color,'w') and not after the surf(X,Y,T). This actually helps in pausing and viewing the surf plot after all the required formatting is done.
Hope it works!

#### 1 件のコメント

Josh Ezekiel 2019 年 10 月 16 日
Hi Divya,
Thank you for the response. I have implemented your suggestion into my code, however the result seems to be more of a 'work around' rather than a fix. The formatting elements of the figure (axis titles, font, font size, etc...) do indeed visibly change, however the latency associated with the generation of each figure--not the 0.01s pause--causes these elements to jitter rapidly. I was wondering whether there was a way of setting the default formatting elements so the only element of the figure that appears to change is the surf(X,Y,T) itself.
Many thanks.

サインイン to comment.

darova 2019 年 10 月 16 日
Use hold on command
%% FORMATING ELEMENTS
figure(1)
xlabel('Width, \$m\$','Interpreter','Latex')
ylabel('Depth, \$m\$','Interpreter','Latex')
zlabel('Temperature, \$T\$','Interpreter','Latex')
xlim([0 Lx])
ylim([0 Ly])
zlim([0 100])
set (gca,'FontSize',10,'FontName','Times')
set(gcf,'color','w');
hold on
while
h = surf(X,Y,T);
pause(0.01)
delete(h);
end
hold off

#### 0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

R2017b

Translated by