Trying to code from Polymath

2 次查看(过去 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

采纳的回答

Rishabh Singh
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 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by