Hello, I am trying to plot the solution to the ordinary second order linear inhomogeneous differential equation:
x''(t)= -x + sin(1.1*t).
I am able to get the solution using the dsolve command, but when I try plotting it using 'plot(x,Solution)', I get an error message saying: 'Warning error updating parametrized function line the following error was reported evaluating the function..' and I can't scroll more to see the full error message.
Any help would be great!

 採用された回答

Star Strider
Star Strider 2019 年 11 月 25 日

0 投票

Use fplot if you have R2016a or later, ezplot otherwise.

6 件のコメント

Louis Sharma
Louis Sharma 2019 年 11 月 25 日
Hi thanks for replying so quick! I forgot to mention that I also tried using fplot but got the same error message..
Star Strider
Star Strider 2019 年 11 月 25 日
My pleasure!
Try this:
syms x(t) t
Dx = diff(x);
Eqn = diff(x,2) == sin(1.1*t) - x;
Xs = dsolve(Eqn, Dx(0) == 0, x(0) == 0) % Include Initial Conditions
figure
fplot(Xs, [0 10])
grid
Louis Sharma
Louis Sharma 2019 年 11 月 25 日
Hi this is great! Thank you so much. This might be a bit much, but since I'm new to Matlab and would like to learn it, could you tell me why my first code didn't work?
Once again thank you!
clear all
syms x(t)
t_min = 0;
t_max= 10;
s = 1.1;
dx = diff(x);
cond_1= x(0) ==1;
cond_2 = dx(0)==0;
conds = [cond_1 cond_2];
ODE= diff(x,t,2) == -x+sin(s*t);
Sol = dsolve(ODE, conds)
Solution = simplify(Sol)
figure
fplot(x,Solution)
Star Strider
Star Strider 2019 年 11 月 25 日
As always, my pleasure!
You did not call fplot correctly. Compare your call to it, and mine.
Call it as:
fplot(Solution, [0 10])
and it works.
Louis Sharma
Louis Sharma 2019 年 11 月 25 日
Amazing! This was really helpful!
Star Strider
Star Strider 2019 年 11 月 25 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by