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..
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
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)
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 Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2019년 11월 25일

댓글:

2019년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by