Matlab no reconoce variable t

5 次查看(过去 30 天)
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.

回答(1 个)

sai charan sampara
sai charan sampara 2023-10-13
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.

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!