Trying to code from Polymath

조회 수: 1 (최근 30일)
Sagarika Bhagat
Sagarika Bhagat 2021년 11월 29일
답변: Rishabh Singh 2021년 12월 6일
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