MATLAB Answers

How to update the title with variable string as time evolution

22 views (last 30 days)
Zong Hua Chen
Zong Hua Chen on 6 Dec 2016
Edited: Zong Hua Chen on 6 Dec 2016
How to update the title with variable string as time evolution
figure(1)
hf=surf(x,y,E.^2)
ha=gca
title(['t=',num2str(0)])
xlabel('k_x')
ylabel('K_y')
zlabel('|E|^2')
dt=0.01;
k=1;
while 1
*****
k=k+1;
t=k*dt;
set(hf,'ZData',E.^2)
set(ha,'Title',text(t))
end
The results appear such problems
Error using text
Invalid parameter/value pair arguments
Error in xxxx (line xx)
set(ha,'Title',text(t))

Accepted Answer

Adam
Adam on 6 Dec 2016
title( ha, sprintf( 't=%f', t ) )
should work

  1 Comment

Sign in to comment.

More Answers (0)

Sign in to answer this question.