I need to loop this operation and store them in a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function stainless_steel(~,~,~)
clear,clc
T_i = [0 0 12.5 25 37.5 50 0];
k = 0.0162;
cp = 0.5;
rho = 8000;
dt = 3;
dx = 0.0125;
t = 120;
q = 20000;
Fo = (k*dt)/(((dx)^2)*rho*cp);
e_gen = q*(dt)/(rho*cp);
n = t/dt;
p = 1;
T_A = zeros(p,7);
for x = 2:6
T(x) = [Fo*(T_i(1,x+1)+273.15 + T_i(1,x-1)+273.15) + (T_i(1,x)+273.15)*(1-2*Fo) + e_gen - 273.15];
end
disp(T)
I need to make the resultant matrix [0 15.9720 27.5000 40.0000 52.5000 60.1400] to be T_i in each loop and store each result in the matrix T_A and I don't now how to do it.
0 Kommentare
Antworten (1)
Walter Roberson
am 2 Dez. 2021
stainless_steel()
function stainless_steel(~,~,~)
T_i = [0 0 12.5 25 37.5 50 0];
k = 0.0162;
cp = 0.5;
rho = 8000;
dt = 3;
dx = 0.0125;
t = 120;
q = 20000;
Fo = (k*dt)/(((dx)^2)*rho*cp);
e_gen = q*(dt)/(rho*cp);
n = t/dt;
p = 1;
T_A = zeros(p,6);
for iteration = 1 : p
for x = 2:6
T(x) = [Fo*(T_i(1,x+1)+273.15 + T_i(1,x-1)+273.15) + (T_i(1,x)+273.15)*(1-2*Fo) + e_gen - 273.15];
end
T_A(iteration, :) = T;
end
T_A
end
1 Kommentar
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!