I have this error!!! ode45
显示 更早的评论
Hello! I have an erroe when using the fuction ode45 this is my code;
clc;
clear all;
close all;
ti=0; h=0.0025; tf=5;
ts=(ti:h:tf);
[renglones,columnas]=size(ts);
opciones=odeset('RelTol',1e-06,'AbsTol',1e-06,'InitialStep',h,'MaxStep',h);
cond_iniciales=1;
[t,F]=ode45('filtro',ts,cond_iniciales,opciones);
Fp=filtro(t,F);
plot(t,Fp)
And this is the function:
function xp=filtro(t,x)
u=Cos(t);
a=3;
b=3;
xp=-a*x+b*u;
end
And the error is:
Error using nargin Error: File: filtroC.m Line: 4 Column: 13 Function with duplicate name "filtroC" cannot be defined.
Error in odearguments (line 60) if (nargin(ode) == 2)
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in pureba (line 10) [t,F]=ode45('filtroC',ts,cond_iniciales,opciones);
2 个评论
James Tursa
2017-9-29
You posted filtro.m twice instead of posting filtroC.m
Jan
2017-9-29
Note: Do not use a string to define the function to be integrated: "ode45('filtroC', ...". This is outdated for 15 years now. Use a function handle as shown in the examples: "ode45(@filtroC, ...".
Show us the contents of "filtroC.m".
回答(1 个)
Walter Roberson
2017-9-29
Your file filtroC has two lines similar to
function outputs = filtroC(arguments)
The second of the two is on line 4 of the file.
2 个评论
Manuel Martinez
2017-9-29
Walter Roberson
2017-9-29
Your error message is
Error in pureba (line 10) [t,F]=ode45('filtroC',ts,cond_iniciales,opciones);
which calls upon filtroC not filtro
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!