Trying to code from Polymath

6 views (last 30 days)
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

Accepted Answer

Rishabh Singh
Rishabh Singh on 6 Dec 2021
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

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!