How to add slicer to the plot with time steps
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
I want to control my graph with time steps. I wish , if i chage slider, my 2D graph changes with time. Time step is 0 to 20 , time step 2,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/353060/image.png)
My code is below, it is a diffusion equation..
clear; clc;syms alfa dx dt eq;
L=0.1;H=0.1;dx=0.01;dy=dx;dt=2;nx=uint32(L/dx+1);ny=uint32(H/dy+1);k=28;
alfa=12*10^-6;g=8*10^5;Ts=30;h=450;Fo=alfa*dt/(dx^2);
[X Y]=meshgrid(linspace(0,L,nx),linspace(0,H,ny));Tint=20;T=Tint*ones(ny,nx)
Tleft=20
Tright=20
Ttop=20
Tbottom=20
T(:,1)=Tleft;T(:,end)=Tright;T(1,:)=Ttop;T(end,:)=Tbottom;
time=20
n=time/dt
s=0
for tt=1:1:n
s=s+1;Tn=T;
for i=2:nx-1
for j=2:ny-1
T(j,i)=(Tn(j,i+1)+Tn(j,i-1)+Tn(j-1,i)+Tn(j+1,i))*Fo+g*dx^2/k*Fo+(1-4*Fo)*Tn(j,i);
end
end
[Xq Yq]= meshgrid(linspace(0,L,nx*5),linspace(0,H,ny*5)); colormap jet
subplot(6,1,[1 4]);title({'DIFFUSION EQUATION',sprintf('Time=%f seconds',s*dt)})
Vq=interp2(X,Y,T,Xq,Yq,'cubic',0);
contourf(Xq,Yq,Vq,20)
hold on
pause(0.5)
end
I want to add slicer and record graph 2 time steps when i used slicer i want to get the contours when 0sec, 2 sec,4sec etc...
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!