dsolve invalid indexing error

4 visualizaciones (últimos 30 días)
Joe Dombroski
Joe Dombroski el 26 de Abr. de 2022
Respondida: Joe Dombroski el 28 de Abr. de 2022
I have a simple diff eqn that is throwing a dsolve error.
Invalid indexing or function definition. Indexing must follow MATLAB indexing.
Function arguments must be symbolic variables, and function body must be sym
expression.
I am guessing it is a simple syntax error, but I just can't see it.
syms y(t) u(t)
Dy = diff(y,t);
D2y = diff(Dy,t);
D3y = diff(D2y,t);
eqn = D3y + 7*D2y + 20*Dy + 24*y == 3*diff(u,t) + 2*u;
cond = [y(0)==0, Dy(0)==1, D2y(0)==-1];
ySol(t) = dsolve(eqn,cond)
  1 comentario
Torsten
Torsten el 26 de Abr. de 2022
Editada: Torsten el 26 de Abr. de 2022
What kind of solution for y do you expect for an unspecified function u(t) ?
That's where the error comes from, I guess.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Abr. de 2022
You have two functions, y and u, but only one differential equation. MATLAB has to decide what to solve for. It essentially uses symvar() and picks the first one... which would be u. u only appears as first derivative, while you have 3 boundary conditions.
The error you get occurs when you have more boundary conditions than you have differential equations.

Más respuestas (1)

Joe Dombroski
Joe Dombroski el 28 de Abr. de 2022
This runs, I just needs to work on how to generate the state equations. Thanks all for the sage advice!
syms y(t) u(t)
Dy = diff(y,t);
D2y = diff(Dy,t);
D3y = diff(D2y,t);
yeqn = D3y + 7*D2y + 20*Dy + 24*y == 0;
ueqn = 3*diff(u,t) + 2*u ==0;
cond = [y(0)==0, Dy(0)==1, D2y(0)==-1];
ySol = dsolve(yeqn,cond)
uSol = dsolve(ueqn)

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by