Input signal and arguments in Ode45. Not enough imput arguments
Mostrar comentarios más antiguos
Hi everybody!
I have an issue when using Ode45. I want to resolve a second order diferential equation where some parameters are fixed and one is a sinusoidal signal.
First of all I get the data from the main:
a=1;
b=1;
c=1;
x_in has the values of a sinusoidal signal
[t,x_sp]=ode45(@Dinamica,[0 20],[0 0]);
The function:
function dx_sp=Dinamica(t,x_sp,a,b,c,x_in)
u=x_sp(1)
v=x_sp(2)
dx_sp=(x_in*a*b^2)-(2*c*b*v)-(u*b^2)
end
¿How should I introuduce those values into my function?
Matlab says: not enough imput arguments.
Thanks!
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 9 de Mzo. de 2021
0 votos
1 comentario
Walter Roberson
el 9 de Mzo. de 2021
However:
x_in has the values of a sinusoidal signal
That implies that it is non-scalar.
dx_sp=(x_in*a*b^2)-(2*c*b*v)-(u*b^2)
All of x_in is used there, so dx_sp would be non-scalar.
[t,x_sp]=ode45(@Dinamica,[0 20],[0 0]);
The boundary conditions are [0 0], a vector of length 2. Your function has to return a column vector the same length, so length 2. Therefore your code would fail unless x_in is a column vector of length 2.
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!