Ordinary Differential Equations (ODEs)

syms t y(t)
ysol=dsolve(' D2y + Dy + 4.25*y = 0','y(0)=2','Dy(0)=1');
y(t)=simplify(ysol)
ezplot(y(t),[0 10]);
xlabel('t');
ylabel('y(t)');
Based on the code block above, I get the following output.
But the output I want to get is as follows.
The formula is as above
I have to use ezplot. How can I get the 2nd output? Where am I making a mistake?

 採用された回答

Star Strider
Star Strider 2021 年 4 月 20 日

1 投票

Change the ezplot call to fplot:
syms t y(t)
ysol=dsolve(' D2y + Dy + 4.25*y = 0','y(0)=2','Dy(0)=1');
Warning: Support of character vectors and strings will be removed in a future release. Use sym objects to define differential equations instead.
y(t)=simplify(ysol)
y(t) = 
fplot(y(t),[0 10]);
xlabel('t');
ylabel('y(t)');
grid
And note the Warning.

4 件のコメント

Kutlu Yigitturk
Kutlu Yigitturk 2021 年 4 月 20 日
I'm asking because I don't know, what's the difference between fplot and ezplot?
Star Strider
Star Strider 2021 年 4 月 20 日
The documentation for fplot and ezplot explains it better than I can. Essentially, fplot is more robust anbd easier to use, although there are some differences.
Kutlu Yigitturk
Kutlu Yigitturk 2021 年 4 月 20 日
Thank you.
Star Strider
Star Strider 2021 年 4 月 20 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics and Optimization についてさらに検索

製品

リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by