solving Tuned Mass Damper using ODE45, need help putting in equation as parameter to solve

3 Ansichten (letzte 30 Tage)
For a tuned mass damper the equations are as follows:
=
=
In matrix form using the companion matrices and
:
= * +
F =
initial condition given vector is
and the interval is
Given the values of the variables the Matrix becomes
=* +
I am told to make a matlab script to solve this numerically and so far i have:
m1 = 1;
m2 = 0.05;
k1 = 1;
k2 = 0;
b1 = 0.001;
b2 = 0;
om = 0.95;
%Numerically solve DE
x0 = [0;0;0;0];
tvec = linspace(0,7000,35000);
A = [ 0, 0, 1, 0;
0, 0, 0, 1;
-(k1+k2)/m1, k2/m1, -(b1+b2)/m1, b2/m1;
k2/m2,-k2/m2, b2/m2,-b2/m2;]
%Hint given to use to solve this:
[t,x] = ode45(@(t,x) ___ + [_;_;_;_],tvec,x0);
I see that in the hint an equation has to go in the red underline plus a column vector. I'm assuming that this column vector that goes affter the plus is .
After i put in the values of the variables in Matrix A and multiplied it by the column vector of [x1; x2; y1; y2;] i get:
and given the subsition i used of does this become

Akzeptierte Antwort

Jan
Jan am 5 Feb. 2022
Bearbeitet: Jan am 5 Feb. 2022
As far as I can see, you have everything you need already.
[t,x] = ode45(@(t,x) A * x + [0; 0; sin(om*t); 0], tvec, x0);
If you write: "No matter what i try i either get an error that the arrays in the equation do not match", post your code an a copy of the error message. Then we can help you.
  1 Kommentar
Proximus
Proximus am 5 Feb. 2022
Bearbeitet: Proximus am 6 Feb. 2022
My apologies, the error was:
Error using +
Matrix dimensions must agree.
And the reason why was because i was manually putting in the equation in there as the column vector of the result of A*x as:
[t,x] = ode45(@(t,x) [x1; x2; -x -b1*x(1);0] + [0; 0; sin(om*t); 0], tvec, x0);
When it didn't dawn upon to just put A*x there instead. Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by