Where in the code, and how should I define y? (A clearer presentation of the question)
1 次查看(过去 30 天)
显示 更早的评论
Hi all, this serves to present the question in a detailed manner. In the attached code, I am trying to solve 7 ODEs,
dydt(1) ... dydt(7).
These ODEs have variable parameters:
CH, CSO2_bulkslurry , E, NSO2, CCO2_bulkslurry, E_CO2, NCO2, CSO3, RCaSO3 and RCaCO3.
In turn, these variable parameters consist of constant parameters and variables. Of which the constant parameters are:
V_Headspace F CSO2_in R Temp HSO2 kga kLa DCa2 DSO2 kLa_CO2 HCO2 DCO2 KSPCaSO3 BETCaSO3 ktot BETCaCO3 MWCaCO3 Kad KCO2 KHCO3 KSO2 KHSO3 Kw CH0
The seven variables are
SO2_g, CO2_g, S_total, C_total, Ca_total, CCaCO3 and CCaSO3.
All I have to do is to solve the 7 ODEs over a period of 183000 seconds.
The equation to evaluate one of the variable parameters, CH ,is rather complicated, and requires fsolve.
CH = fsolve(@(CH) CH + 2.* Ca_total - ((S_total.* KSO2.*CH)/(CH^2 + KSO2.*CH + KSO2.*KHSO3))- 2.*((S_total.*KSO2.*KHSO3)/(CH^2
+ KSO2.*CH + KSO2.*KHSO3))-((C_total.*KCO2.*CH)/(CH^2 + KCO2.*CH + KCO2.*KHCO3))- 2.*((C_total.*KCO2.*KHCO3)/(CH^2 + KCO2.*CH + KCO2.*KHCO3))- Kw/CH, CH0);
As a result, I thought of just using a vector of experimental values.
CH = [7.41E-06;9.33E-06;1.20E-05;1.05E-05;1.74E-05;3.72E-05;3.55E-05;1.00E-04;4.07E-02;2.45E-01; 6.17E-01;1.32E+00;2.29E+00;2.34E+00;2.40E+00;1.82E+00;1.38E+00;2.09E+00;1.82E+00;1.58E+00; 2.29E+00;1.62E+00;1.12E+00;8.91E-01;8.51E-01;7.59E-01;8.71E-01;1.12E+00;1.00E+00;8.51E-01];
I hope I unpacked the question sufficiently.
When I run the attached code, I get the error message
Undefined function or variable 'y'.
Error in eulerian1 (line 47)
y = y0 + odesfun(t,y,Parameter).'*delta;
Which alerts me to define y. My question is where in the code, and how should I define y?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!