ODE45 error message "Error using exist The first input to exist must be a string scalar or character vector"

조회 수: 9 (최근 30일)
Below is my code to solve a population balance:
global param w0 w
param0=[1 1 1 1]
param=param0
param=fminsearch(lau,param0)
psi_lau=param(1)
alfa_lau=param(2)
beta_lau=param(3)
epsilon_lau=param(4)
function sse=lau(param)
global param w0 w t
w0=[0.1 0.2 0.23 0.4 0.2 0.1 0.1 0.01];
w=w0
t0=[0 0 0 0 0 0 0 0];
tp=[5 5 5 5 5 5 5 5];
t=t0
[t,w]=ode45(grinding,[t0 tp],w0)
wdata= [1 1 1 1 1 1 1 1 ; % weight fraction pada t=60
1 1 1 1 1 1 1 1 ; % weight fraction pada t=120
1 1 1 1 1 1 1 1 ; % weight fraction pada t=180
1 1 1 1 1 1 1 1 ; % weight fraction pada t=240
1 1 1 1 1 1 1 1 ]; % weight fraction pada t=300
%w= (2*param(1)^2).*wdata; % weight fraction hasil simulasi
sse=sum(sum((wdata-w).^2)'); % sums of square error
end
function dwdt=grinding(t,w)
global param w0 w
x=[0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2];
w
param
for k=1:length(x)
S(k)=(param(2)*x(k)^param(3))/(1+x(k)^param(4));
for u=2:k
deltaB(k,u)=((x(k-1))/x(u))^param(1)-((x(k)/x(u))^param(1));
end
end
for k=1:length(x)
WS(k)=w(k).*S(k);
end
S
deltaB
summation=WS*deltaB
for k=1:length(x)
dwdt(k)=summation(k)-S(k)*w(k);
end
dwdt
end
It trigger an error of
Error using exist
The first input to exist must be a string scalar or character vector.
Error in odearguments (line 59)
if (exist(ode)==2)
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Optimize>lau (line 26)
[t,w]=ode45(grinding,[t0 tp],w0)
Error in Optimize (line 8)
param=fminsearch(lau,param0)
Could anybody help to solve the issue, sorry to put a lot of tracker for debuging purpose, thanks

채택된 답변

Torsten
Torsten 2019년 2월 5일
편집: Torsten 2019년 2월 5일
param = fminsearch(@lau,param0)
[t,w] = ode45(@grinding,[t0 tp],w0)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by