ODE23 errorline 114)
古いコメントを表示
clc;clearvars; close all; format short g; format compact;
global PT S DELH Q CPA CPB CPC CPD NA NC NB ND NE NT;
PT = 1.5; % PT is total pressure in atmospheres
S = 0.05; % S= 0.5 square meters of area
DELH = 206014; % DELH is heat of reaction in Joules per gram mole
Q = 5000; % Heat input rate per unit lenth of bed (Joules/min-meter)
CPA = 36.9607; % specific heat (J/gmole-K)
CPB = 33.7295; % specific heat (J/gmole-K)
CPC = 29.1668; % specific heat (J/gmole-K)
CPD = 28.6455; % specific heat (J/gmole-K)
zz0 = 0.0;
zzf = 0.5;
YY0 = [3;3.5;0;0.000001;1300];
[zz,YY] = ode23('chrlspr3',zz0,zzf,YY0);
K = 0.45; % For now, K is assumed to be independent of temperature, K = constant
NA= YY(:,1);
NB= YY(:,2);
NC= YY(:,3);
ND= YY(:,4);
T = YY(:,5);
NE= .45* YY(:,3).* YY(:,2)./YY(:,4);
NT= NA+NB+NC+ND+NE;
plot(zz,NA,'r+',zz,NB,'g-')
title('MOLES/MIN versus REACTOR LENGTH')
xlabel(' Reactor Length')
ylabel('Gram-moles/min')
grid
pause, close
plot(zz,NC,'b-.',zz,ND,'y--',zz,NE,'r+')
title('MOLES/MIN versus REACTOR LENGTH')
xlabel(' Reactor Length')
ylabel('Gram-moles/min')
grid
pause, close
plot(zz,T)
title('TEMPERATURE versus REACTOR LENGTH')
xlabel('Reactor Length')
ylabel('TEMPERATUTE 0 K')
grid
function W =chrlspr3(zz,YY)
global PT S DELH Q CPA CPB CPC CPD NA NB NC ND NE NT T;
%S= 0.01;
NT =YY(1)+YY(2)+YY(3)+YY(4)+(0.45* YY(3)* YY(2)/ YY(4)); % Keq=0.45
NTCP=YY(1)*CPA + YY(2)*CPB + YY(3)*CPC + YY(4)*CPD; % Sigma Ni CP1
W(1)=-1.02*(10^6)*S*(0.10949*PT*YY(1)/NT)/(1+0.239*YY(2)/YY(4)+17.62*YY(3)*PT/NT);
W(2)=-1.02*(10^6)*S*(0.10949*PT*YY(1)/NT)/(1+0.239*YY(2)/YY(4)+17.62*YY(3)*PT/NT);
W(3)=1.02*(10^6)*S*(0.10949*PT*YY(1)/NT)/(1+0.239*YY(2)/YY(4)+17.62*YY(3)*PT/NT);
W(4)=3*1.02*(10^6)*S*(0.10949*PT*YY(1)/NT)/(1+0.239*YY(2)/YY(4)+17.62*YY(3)*PT/NT);
W(5)=(-S*DELH*W(3)+Q)/(NTCP); %DT/Dz equation
end
回答 (1 件)
Cris LaPierre
2020 年 12 月 22 日
編集済み: Cris LaPierre
2020 年 12 月 22 日
Read the full error message.
The last entry in tspan must be different from the first entry.
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
The first error is the one you need to fix. You have not defined tspan correctly. Read more about what the correct inputs can be in the documenation. Also, you'll need to update the syntax used to call your ode function.
[zz,YY] = ode23(@chrlspr3,[zz0,zzf],YY0);
Then you'll get an error that CHRLSPR3 must return a column vector. Include a column index of 1 to each of your assignments to w in your ode function.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!