Having error "Can't define variable t"

function dydt = problem(t,y)
dydt= 5*exp(4*t)-3*y;
end
tspan=[0,1];
initial=10;
[t,y]= ode45(@problem,tspan,initial);
plot(t,y,'-o');
-----------------------------
Hi this is my code and I am having difficulties to run this code.
How can I fix it?
Directions keep telling me that "Can't define variable t"
Do i need to reinstall MATLAb?

 採用された回答

KSSV
KSSV 2021 年 10 月 8 日

0 投票

Why do you want to reinstall MATLAB? You are not running the function/ code properly. Copy your code in a single file, make it a function and run it. OR save the function problem into a file and run the code another file or in workspace.
tspan=[0,1];
initial=10;
[t,y]= ode45(@problem,tspan,initial);
plot(t,y,'-o');
function dydt = problem(t,y)
dydt= 5*exp(4*t)-3*y;
end

1 件のコメント

JU YEON SIM
JU YEON SIM 2021 年 10 月 8 日
Extremely thanks
I gotcha

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2021 年 10 月 8 日

コメント済み:

2021 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by