Error using Odearguments - vector must return a column

조회 수: 3 (최근 30일)
Anh Bui
Anh Bui 2024년 4월 17일
댓글: Star Strider 2024년 4월 17일
I kept on trying to reword and rearrange my code however it asked me to do it so that the line return a column vector. I tried reshape(), [],1, (does not work). Also tried .' at the end which also doesnt work. I'm not sure where I can continue with this?
%r_H2= -(-Rds - Rwf - Rh);
%Rd = kds*(CH20*((theta_O2-X)/(1+eps*X)))*(CH20*((1-X)/(1+eps*X)))^2
%Rwf = kwf* (CH20*((theta_O2-(b/a)*X)/(1+wf_eps*X)))^.5*CH20.*((1-X)./(1+wf_eps*X))
%Rh = kh* (CH2O2*(theta_H2-(d_b/d_a)*X)) *CH2O2*(1-X)
wspan = [0 1000];
dxdw = @(W,X)(kds.*(CH20.*((theta_O2-X)./(1+eps.*X))).*(CH20.*((1-X)./(1+eps.*X))).^2 + ...
kwf.* (CH20.*((theta_O2-(b/a).*X)./(1+wf_eps.*X))).^.5*CH20.*((1-X)./(1+wf_eps.*X))+ kh.* (CH2O2.*(theta_H2-(d_b/d_a).*X)) .*CH2O2.*(1-X));
IC = [0 0 0 0 0 0 0 0 0 0 0];
[W,X] = ode45(dxdw,wspan,IC);
plot(W,X)
title ('Catalyst v.s Conversion')
xlabel('Weight of Catalyst (kg)')
ylabel('Conversion of H2')

채택된 답변

Star Strider
Star Strider 2024년 4월 17일
You only have one differential equation, so only one initial condition is necessary.
%r_H2= -(-Rds - Rwf - Rh);
%Rd = kds*(CH20*((theta_O2-X)/(1+eps*X)))*(CH20*((1-X)/(1+eps*X)))^2
%Rwf = kwf* (CH20*((theta_O2-(b/a)*X)/(1+wf_eps*X)))^.5*CH20.*((1-X)./(1+wf_eps*X))
%Rh = kh* (CH2O2*(theta_H2-(d_b/d_a)*X)) *CH2O2*(1-X)
wspan = [0 1000];
dxdw = @(W,X)(kds.*(CH20.*((theta_O2-X)./(1+eps.*X))).*(CH20.*((1-X)./(1+eps.*X))).^2 + ...
kwf.* (CH20.*((theta_O2-(b/a).*X)./(1+wf_eps.*X))).^.5*CH20.*((1-X)./(1+wf_eps.*X))+ kh.* (CH2O2.*(theta_H2-(d_b/d_a).*X)) .*CH2O2.*(1-X));
% IC = [0 0 0 0 0 0 0 0 0 0 0];
IC = eps;
[W,X] = ode45(dxdw,wspan,IC);
Unrecognized function or variable 'kds'.

Error in solution>@(W,X)(kds.*(CH20.*((theta_O2-X)./(1+eps.*X))).*(CH20.*((1-X)./(1+eps.*X))).^2+kwf.*(CH20.*((theta_O2-(b/a).*X)./(1+wf_eps.*X))).^.5*CH20.*((1-X)./(1+wf_eps.*X))+kh.*(CH2O2.*(theta_H2-(d_b/d_a).*X)).*CH2O2.*(1-X)) (line 6)
dxdw = @(W,X)(kds.*(CH20.*((theta_O2-X)./(1+eps.*X))).*(CH20.*((1-X)./(1+eps.*X))).^2 + ...

Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
plot(W,X)
title ('Catalyst v.s Conversion')
xlabel('Weight of Catalyst (kg)')
ylabel('Conversion of H2')
All the missing constants prevent me from running this.
.
  댓글 수: 4
Anh Bui
Anh Bui 2024년 4월 17일
Thank you so much !!!
Star Strider
Star Strider 2024년 4월 17일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
Torsten 2024년 4월 17일
이동: Torsten 2024년 4월 17일
This works - although I'm not sure if it is what you want:
wspan = [0 1000];
CH2O2 = @(X)CH20.*((theta_H2O2+X)./(1+eps*X))*T0T*PP0;
dxdw = @(W,X)(kds.*(CH20.*((theta_O2-X)./(1+eps.*X))).*(CH20.*((1-X)./(1+eps.*X))).^2 + kwf.* (CH20.*((theta_O2-(b/a).*X)./(1+wf_eps.*X))).^.5*CH20.*((1-X)./(1+wf_eps.*X))+ kh.* (CH2O2(X).*(theta_H2-(d_b/d_a).*X)) .*CH2O2(X).*(1-X));
IC = eps*ones(11,1);
[W,X] = ode15s(dxdw,wspan,IC);
And better use a variable name different from eps. It usually is a predefined constant is MATLAB:
eps
ans = 2.2204e-16

카테고리

Help CenterFile Exchange에서 Chemistry에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by