フィルターのクリア

Solve the ODE using ODE45 and plot the response for the initial conditions

2 ビュー (過去 30 日間)
Kashmira Vinay
Kashmira Vinay 2022 年 10 月 22 日
回答済み: Jan 2022 年 10 月 23 日
funtion xdot = ode45(x, t);
xdot = x^4 - 7*x^2 + 6*x;
%Plotting Data
%x(0) = -3.5
subplot(311)
t = (0: 0.01 : 0.5);
x = ('ode45'; -3.5; t);
plot (t,x)
%x(0) = -0.2
subplot(312)
t = (0: 0.01 : 0.5);
x = ('ode45'; -0.2; t);
plot (t,x)
%x(0) = 1.1
subplot(313)
t = (0: 0.01 : 0.5);
x = ('ode45'; 1.1; t);
plot (t,x)
%x(0) = 2.5
subplot(314)
t = (0: 0.01 : 0.5);
x = ('ode45'; 2.5; t);
plot (t,x)
endfunction
  1 件のコメント
Star Strider
Star Strider 2022 年 10 月 22 日
Your ‘ode45’ function is going to overshadow the ode45 function you are going to need to solve whatever it is you want to do.

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

回答 (1 件)

Jan
Jan 2022 年 10 月 23 日
If you call a function "ode45", it depends on where its folder is located in Matlab's path, if it is used or the original ODE45 function of Matlab. This is called "shadowing". Avoid to use names of built-in Matlab functions for your own variables and functions, because this causes many troubles.
subplot(311)
This notation is deprecated since Matlab 5.0 (1996). Use subplot(3,1,1) or the modern tiledlayout (since R2021a).
This line is not meaningful:
x = ('ode45'; -3.5; t);
Remember, that this is a Matlab forum. "endfunction" is not Matlab, but might be Octave.
Please take the time to ask a specific question.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by