I have this error!!! ode45
Mostra commenti meno recenti
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 Commenti
James Tursa
il 29 Set 2017
You posted filtro.m twice instead of posting filtroC.m
Jan
il 29 Set 2017
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".
Risposte (1)
Walter Roberson
il 29 Set 2017
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 Commenti
Manuel Martinez
il 29 Set 2017
Walter Roberson
il 29 Set 2017
Your error message is
Error in pureba (line 10) [t,F]=ode45('filtroC',ts,cond_iniciales,opciones);
which calls upon filtroC not filtro
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!