minor editing of current code of displaying 3 timestamps to displaying multiple timestamps with for and pause command

1 view (last 30 days)
I did this code that displays the first 3 timestamps for temperature difference, but now i need to use for loop and pause command to change it to show multiple timestamps and how it changes each step with the pause command. I have edited it but its still wrong.
%%first 3 timestamps
n=5;
dt=1000;
k=15;
rho=8055;
Cp=480;
deltax=1.6;
x=linspace(-0.8,0.8,n);
deltax = x(2)-x(1);
T=zeros(1,5); T(1,1)=40; T(1,5)=40;
figure
plot(x,T)
title('Temperature distribution for first 3 timestamps')
xlabel('x')
ylabel('Temperature')
hold on;
T_old = T;
T(2:end-1) = T_old(2:end-1) + k/(rho*Cp) * dt * (T_old(3:end)-2*T_old(2:end-1)+T_old(1:end-2))/(deltax.^2);
plot(x,T)
hold on
T_old = T;
T(2:end-1) = T_old(2:end-1) + k/(rho*Cp) * dt * (T_old(3:end)-2*T_old(2:end-1)+T_old(1:end-2))/(deltax.^2);
plot(x,T)
%%multiple timestamps
n=5;
dt=1000;
k=15;
rho=8055;
Cp=480;
deltax=1.6;
x=linspace(-0.8,0.8,n);
deltax = x(2)-x(1);
T=zeros(1,5); T(1,1)=40; T(1,5)=40;
t = 0;
dt = 1000;
for c = 1:t
for r = 1:t
T(r,c) = 1/(r+c-1);
pause(1000);
end
end
figure
plot(x,T)
title('Temperature distribution for first multiple timestamps')
xlabel('x')
ylabel('Temperature')

Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by