1
$\begingroup$

I have a mass - spring - damper system with external force and I am trying to simulate it using Matlab. I want to have a linearly parameterized form and use the least squares method to find the estimators. I have reached the stage where I have the form:

$$ y = \theta^T z $$ $$\theta = [\theta_1 \ \ \theta_2 \ \ \theta_3]^T$$ $$z = [-s\frac{y}{Λ(s)} \ \ -\frac{y}{Λ(s)} \ \ \frac{u}{Λ(s)}]^T$$

where $\ Λ(s) $ is a stable filter $\ Λ(s) = s^2 + 3s + 2 $ and $\ y $ is the output of the system (the mass relocation) and $\ u $ is the input of the system (the external force).

I am trying to calculate the elements of $\ z $ vector and for $\ z_1 = -s\frac{y}{Λ(s)} $ for example I have done the following:

$$ z_1 = -s\frac{y}{Λ(s)} \Rightarrow \ddot{z_1}+3\dot{z_1}+2z_1 = -\dot{y} $$

$$x_1 = z_1 \Rightarrow \dot{{x_1}} = x_2 - y$$

$$x_2 = \dot{z_1}+y \Rightarrow \dot{{x_2}} = -3x_2 - 2x_1 + 3y$$

From now on I want to use the ode45(...) function but I am not able to figure out how to finally calculate $\ z_1 $ and then put it in the $\ z $ vector.

$\endgroup$
0
$\begingroup$

This is how the whole backward vector $\ z $ is computed using matlab ode45(...) solver:

tspan - 0:0.01:10; 

eqtn = @(t,x,y) [x(2)-interp1(tspan(:),y(:),t) ; -3*x(2)-2*x(1)+3*interp1(tspan,y(:),t)];
x = [0;0];
[~,phi_1] = ode45(@(t,x)eqtn(t,x,y),tspan, x);


eqtn = @(t,x,y) [x(2) ; -3*x(2)-2*x(1)-interp1(tspan,y(:),t)];
x = [0;0];
[~,phi_2] = ode45(@(t,x)eqtn(t,x,y),tspan, x);


eqtn = @(t,x,u) [x(2) ; -3*x(2)-2*x(1)+interp1(tspan,u(:),t)];
x = [0;0];
[~,phi_3] = ode45(@(t,x)eqtn(t,x,u),tspan, x);

z = [phi_1(:,1) phi_2(:,1) phi_3(:,1)];

It is assumed that the vectors $\ y \ \& \ u $ are known and represent the output and the input of the original system correspondingly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.