Error in ODE arguments in line 87
Show older comments
Hi everyone!
I'm trying to reed a .m funtion (with global variables) with the following script:
function [dY]=fun2(t,yfo)
for i=1:ng
for j=1:ng
if i~=j
aux2_pe=C_fal(i,j)*sin(yfo(i)-yfo(j))+D_fal(i,j)*cos(yfo(i)-yfo(j));
end
end
Pe_fal(i,1)=vg(i)^2*real(y_fal(i,i))+aux2_pe;
dy(i+ng)=(Pm(i)-Pe_fal(i,1))/M(i);
dy(i)=yfo(i+ng);
end
dY=[dy(1); dy(2); dy(3); dy(4); dy(5); dy(6)]
end
using the following codes for ODE23s:
yfo=[0.4677 0.4625 0.1171 0 0 0];
tspan=[0:0.002:0.198];
[tf,yf]=ode45('fun2',tspan,yfo);
and obtaining the following answer:
Undefined function or variable 'ng'.
Error in fun2 (line 5)for i=1:ng
Error in odearguments (line 87)
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 Untitled2 (line 246) [tf,yf]=ode45('fun2',tspan,yfo);
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!