Error using Odearguments - vector must return a column

3 vues (au cours des 30 derniers jours)
Anh Bui
Anh Bui le 17 Avr 2024
Commenté : Star Strider le 17 Avr 2024
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')

Réponse acceptée

Star Strider
Star Strider le 17 Avr 2024
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 commentaires
Anh Bui
Anh Bui le 17 Avr 2024
Thank you so much !!!
Star Strider
Star Strider le 17 Avr 2024
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Torsten
Torsten le 17 Avr 2024
Déplacé(e) : Torsten le 17 Avr 2024
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

Catégories

En savoir plus sur Chemistry dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by