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)

 Respuesta aceptada

Star Strider
Star Strider el 28 de Dic. de 2020

1 voto

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 comentarios

Sajith Srimal
Sajith Srimal el 28 de Dic. de 2020
Thanks
Star Strider
Star Strider el 28 de Dic. de 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 28 de Dic. de 2020

Comentada:

el 28 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by