Trying to code from Polymath
1 回表示 (過去 30 日間)
古いコメントを表示
Im supposed to turn this Polymath code into a Matlab code but Im not sure how. Please help. Its supposed to use an ode solver and a graph
0 件のコメント
採用された回答
Rishabh Singh
2021 年 12 月 6 日
Hi Sagarika,
Below is the code for MATLAB Version.
% Initial conditions
X0 = 0;
T0 = 450;
Ta0 = 323;
IC = [X0 T0 Ta0];
% W range
Wspan = [0 50];
% Call ode solver
[W, CT] = ode45(@fn, Wspan, IC);
% Extract parameters
X = CT(:,1);
T = CT(:,2);
Ta = CT(:,3);
% Plot graphs
figure
plot(W,X,W,T,W,Ta),grid
xlabel('W'),ylabel('X.T.Ta')
legend('X','T','Ta')
figure
plot(W,T),grid
xlabel('W'),ylabel('T')
% ODE function
function dCTdW = fn(~,CT)
% Data
V0 = 20;
T0 = 450;
Uabyrho = 0.08;
CPc = 5000;
mc=0.2;
P0 = 1013250;
% Extract parameters
X = CT(1);
T = CT(2);
Ta = CT(3);
%supporting functions
k = 0.133*exp(31400/8.314*(1/T0 - 1/T));
CA0 = P0/(8.314*T0);
CA = CA0*(1-X)*(T0/T)/(1+X);
rA = -k*CA;
% odes
dCTdW = [(k*(1-X)*T0)/(V0*(1+X)*T);
(Uabyrho*(Ta-T)+rA*20000)/(V0*CA*40);
(Uabyrho*(T-Ta)/(mc*CPc))];
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!