ode(t) =
How to fix "Error using indexing" while calculating differential equations?
Mostra commenti meno recenti
syms y(t)
ode = diff(y,t) == t*y
ySol(t) = dsolve(ode)
I copied this example straight from the MatLAB "Solve differential equations" > "First-Order Linear ODE" -example and hoped to modify it to solve my own equation, but it gives me an error message of "Error using indexing: Invalid argument at position 2. Symbolic function expected 1 input arguments but received 2.". I have no clue how to fix it, so help would be kindly appreciated.
3 Commenti
Torsten
il 29 Giu 2024
As you can see above, the example works with MATLAB R2024a. What's your MATLAB version ?
Iita
il 29 Giu 2024
I don't see any changes made in "dsolve" from R2023a to R2024a, but you can try.
Do you get the same error with this code ? Or does the error happen later on in your code when you try to manipulate ySol ?
syms y(t)
ode = diff(y,t) == t*y;
ySol = dsolve(ode)
Risposte (1)
John D'Errico
il 30 Giu 2024
Modificato: John D'Errico
il 30 Giu 2024
The code you show will work perfectly in MATLAB, in literally any recent release of MATLAB. R2023 is entirely recent.
However, it is very possible that you have defined a variable named diff in your workspace. For example, let me do this:
syms y(t)
diff(t) = y(t)
ode = diff(y,t) == t*y
Do you see that I have gotten exactly the same error you were given?
Do this at the command line:
whos diff -all
And then delete the variable named diff.
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!