clear clc
xss=0.01;
omegaf = 40;
omegan = 20;
n=0.1;
syms x(t) A B
v(t) = diff(x,t);
x0 =0.05;
v0 =2;
eq1 = xss * cos(omegaf*t) + (A*sin(omegan*t) +B* cos(omegan*t))*exp(-n*omegan*t) == x;
eq2 = diff(eq);
eq3 = subs( eq1 , [x(t),t] , [x0,0]);
eq4 = subs( eq2 , [v(t),t] , [v0,0]);
[D,C] = equationsToMatrix([eq3,eq4],[A,B]);
Res = linsolve(D,C);
eq1 = subs(eq1, [A,B] ,[Res(1),Res(2)]);
t=0:4;
plot(t,eq1)

 採用された回答

Star Strider
Star Strider 2020 年 12 月 28 日

1 投票

The ‘eq1’ expression is not written correctly with respect to its being a function off one variable.
Try this:
xss=0.01;
omegaf = 40;
omegan = 20;
n=0.1;
syms x(t) A B
v(t) = diff(x,t);
x0 =0.05;
v0 =2;
eq1 = xss * cos(omegaf*t) + (A*sin(omegan*t) +B* cos(omegan*t))*exp(-n*omegan*t) == x;
eq2 = diff(eq1);
eq3 = subs( eq1 , [x(t),t] , [x0,0]);
eq4 = subs( eq2 , [v(t),t] , [v0,0]);
[D,C] = equationsToMatrix([eq3,eq4],[A,B]);
Res = linsolve(D,C);
eq1 = subs(eq1, [A,B] ,[Res(1),Res(2)])
eq1 = lhs(eq1); % Use Only Left-Hand-Side For 'eq1’
% t=0:4;
fplot(eq1, [0 4])
This plots only the left-hand-side of the expression (using the lhs function), and uses fplot rather than plot.

2 件のコメント

Sajith Srimal
Sajith Srimal 2020 年 12 月 28 日
Thanks
Star Strider
Star Strider 2020 年 12 月 28 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by