Why does matlab request me to define a for-loop indexing term?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
I am trying to run the attached code, but matlab gives this error:
Undefined function or variable 'k'.
Error in SlurryCaseODE45Feb18>DifEq (line 212)
dcdt(1) = (1/V_Headspace) * (F * CSO2_in - F * c(1) )- ((((c(1)*R*T - ((c(3)*CH(k)^2)/(CH(k)^2 + KSO2*CH(k) + KSO2*KHSO3)) *
HSO2))/((1/kga) + (HSO2/(1 + ((DCa2 .* c(5))/(DSO2 .* c(3)))) * kLa_SO2))));
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in SlurryCaseODE45Feb18 (line 142)
[t,Cv]=ode45(@DifEq,tspan,c0,Options);
Why does matlab request me to define k?
Please help.
0 件のコメント
採用された回答
Walter Roberson
2019 年 2 月 14 日
Variables defined inside one workspace are not visible inside another workspace (the function) unless they are specifically passed in or otherwise imported.
See paramfun
However, you have
for k = 1: length(t)
[t,Cv]=ode45(@DifEq,tspan,c0,Options);
end
Even if you were to pass k in specifically for use, then you would have the problem that you are overwriting t and Cv each iteration of k, so you would be throwing away all of the results except the last one.
You also use tv in several plot statements but you have not assigned anything to tv anywhere.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!