Matlab no reconoce variable t
4 views (last 30 days)
Show older comments
Buenas, estoy intentando resolver un sistema de EDO de 6 ecuaciones mediante ode45, el caso es que al darle a compilar me dice que la variable t es no reconocida.
0 Comments
Answers (1)
sai charan sampara
on 13 Oct 2023
Hello Cristina,
I understand that you are trying to use “ode45” to solve system of equations but getting an error that variable “t” is not recognised.
This might be happening because of wrong function handles. When the equations or function handles are defined you should also include the variable “t” in the list of variables. It should be done like the example below.
yprime = @(t,y) -2*y + 2*cos(t).*sin(2*t);
Or during the call of “ode45” function add the variables in the input as below.
[t,y] = ode45(@(t,y) 2*t, tspan, y0);
Not including “t” in the above handle, in the bracket after “@” might be causing the error. Even if the equations do not involve “t” it should be added because they are differential equations with respect to time.
You can refer to the below documentation to learn more about ode45.
Hope this helps.
Thanks,
Charan.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!