Below is my code to solve a population balance:
global param w0 wparam0=[1 1 1 1] param=param0param=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 tw0=[0.1 0.2 0.23 0.4 0.2 0.1 0.1 0.01];w=w0t0=[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
endfunction dwdt=grinding(t,w)global param w0 wx=[0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2];wparamfor 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)); endendfor k=1:length(x) WS(k)=w(k).*S(k);endSdeltaBsummation=WS*deltaBfor k=1:length(x)dwdt(k)=summation(k)-S(k)*w(k);enddwdtend
It trigger an error of
Error using existThe 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
Best Answer