Linear differential equation code errors

I'm trying to solve
y = sqrt(x*dx/dt) or y=-sqrt(x*dx/dt)
with a function and ode 45 and i get several errors
function f=dif32(t,x);
f=[sqrt(x*dx/dt);-sqrt(x*dx/dt)];
***********
T=[0,10];
x0=[sqrt(2),0]
[t,x]=ode45(@dif32,T,x0);
plot(t,x),grid,title('dif'),legend('x1''x2')
Undefined function or variable 'dx'.
Error in dif32 (line 2)
f=[sqrt(x*dx/dt);-sqrt(x*dx/dt)];
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in Untitled4 (line 3)
[t,x]=ode45(@dif32,T,x0);

3 comentarios

John D'Errico
John D'Errico el 9 de En. de 2022
Editada: John D'Errico el 9 de En. de 2022
This is now the 4th time you have asked the exact same question. You have gotten an answer on at least one of them Stop posting it over and over again.
Read the help for ode45, where you will find examples of usage. Note that in MATLAB, you don't write a derivative as dx/dt, and just hope that MATLAB will know that you intended that as a derivative.
Finally, this is NOT a linear differential equation.
James Sm.
James Sm. el 9 de En. de 2022
as i said before im new to matlab and i want to get into it that's why im asking for help with the code
John D'Errico
John D'Errico el 9 de En. de 2022
You got an answer to exactly the same question from Torsten. If you have a question where you don't understand the solution he gave, then ask it of him there.

Respuestas (0)

La pregunta está cerrada.

Productos

Versión

R2015a

Preguntada:

el 9 de En. de 2022

Cerrada:

el 9 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by