# How to fix "Error using indexing" while calculating differential equations?

조회 수: 7 (최근 30일)
Iita 2024년 6월 29일
편집: John D'Errico 2024년 6월 30일
syms y(t)
ode = diff(y,t) == t*y
ode(t) =
ySol(t) = dsolve(ode)
ySol(t) =
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이전 댓글 1개 표시이전 댓글 1개 숨기기
Iita 2024년 6월 29일
Ah, I've got the R2023a version. I imagine an update would fix things quite efficiently :,D
Torsten 2024년 6월 29일
편집: Torsten 2024년 6월 29일
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)
ySol =

댓글을 달려면 로그인하십시오.

### 답변 (1개)

John D'Errico 2024년 6월 30일
편집: John D'Errico 2024년 6월 30일
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)
diff(t) =
ode = diff(y,t) == t*y
Error using indexing (line 249)
Invalid argument at position 2. Symbolic function expected 1 input arguments but received 2.
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.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by