Mathematical bretheren, lend me your brains

We may earn a small commission from affiliate links and paid advertisements. Terms

GSRCRXsi

Super Moderator
VIP
ok so i have this homework in my Automatic controls class. i understand the concepts but for whatever reason i just cant get this problem to work out. i think its a problem with my modeling but im not sure. this is basically a system response problem. where i have some masses suspended by springs and dampers. the objective is to come out with the funtions for y1, and y2 (the displacements of the blocks where positive is downward) where i have 2 inputs u1 and u2 which will be constant forces. when i run it in matlab, im getting propagation rather than dampening, which is obviosly wrong. also since its multiple input (and linear) i have to treat this system as 2 single inputs working with the applied forces seperately and then adding them together in the end. the steps ive followed from my example are straight forward although it was only for a single input.

step 1: Identify input/output relationships
step 2: draw the FBD in the time domain
step 3: draw the FBD in the s domain (La Place transform)
step 4: arrange the equations
step 5: put them in matrix format
step 6: apply cramers rule to get the transfer funtions
step 7: go into matlab for the simulation and plots of y1, y2

heres my work along with the matlab code:

Code:
% HW #2 - Problem #1

%Coefficients
m1=4;
m2=7;
k1=4.2;
k2=5.7;
b1=3.2;

% DEN(s) 
aden=m1*m2;
bden=m1*b1+m2*b1;
cden=m1*k1+m2*k1;
dden=k1*b1+k2*b1;
eden=k1*k2;
den=[aden bden cden dden eden];

%NUM_11(s)
anum_11=m2;
bnum_11=b1;
cnum_11=k2;
num_11=[anum_11 bnum_11 cnum_11];

%NUM_21(s)
anum_21=b1;
bnum_21=0;
num_21=[anum_21 bnum_21];

%NUM_12(s)
anum_12=b1;
bnum_12=0;
num_12=[anum_12 bnum_12];

%NUM_22(s)
anum_22=m1;
bnum_22=b1;
cnum_22=k1;
num_22=[anum_22 bnum_22 cnum_22];

roots(den)
%Time vector
t=(0:0.05:60);
t=t';
%Introduce applied forces
for i=1:1201
    ua1(i)=2;
    ua2(i)=4;
end;
%Simulation using LSIM
sys1=tf(num_11,den);
sys2=tf(num_12,den);
sys3=tf(num_21,den);
sys4=tf(num_22,den);

y1_1=lsim(sys1,ua1,t);
y1_2=lsim(sys2,ua2,t);
y1=y1_1+y1_2;

y2_1=lsim(sys3,ua1,t);
y2_2=lsim(sys4,ua2,t);
y2=y2_1+y2_2;

%Plots y1 in green, y2 in red
subplot(211), plot(t,y1,'g');
subplot(212), plot(t,y2,'r');
 

Attachments

  • hw1.jpg
    hw1.jpg
    68.6 KB · Views: 95
  • hw2.jpg
    hw2.jpg
    65.9 KB · Views: 78
  • hw3.jpg
    hw3.jpg
    55.9 KB · Views: 87
  • hw4.jpg
    hw4.jpg
    57.2 KB · Views: 88
A few things:

Although its a simple problem, your comments are too short. You also didn't make your "roots(den)" statement stand out. I couldn't find it to suppress the output. And your plot has no labeling - not to say it was the last iteration of your code, but practice makes perfect. And you haven't listed units.

"Cden" definition was also not consistant with your notes. Most likely the problem.

Lastly, your way of defining your force vector is not proper for matlab. Loops just waste time - especially for constant vectors.




Below is my changed code:

Code:
% HW #2 - Problem #1
 
%Coefficients
m1=4;
m2=7;
k1=4.2;
k2=5.7;
b1=3.2;
 
% DEN(s) 
aden=m1*m2;
bden=m1*b1+m2*b1;
cden=m1*k2+m2*k1;
dden=k1*b1+k2*b1;
eden=k1*k2;
den=[aden bden cden dden eden];
 
%NUM_11(s)
anum_11=m2;
bnum_11=b1;
cnum_11=k2;
num_11=[anum_11 bnum_11 cnum_11];
 
%NUM_21(s)
anum_21=b1;
bnum_21=0;
num_21=[anum_21 bnum_21];
 
%NUM_12(s)
anum_12=b1;
bnum_12=0;
num_12=[anum_12 bnum_12];
 
%NUM_22(s)
anum_22=m1;
bnum_22=b1;
cnum_22=k1;
num_22=[anum_22 bnum_22 cnum_22];
 
%Roots of the Den vector
roots(den);
 
%Time vector (MY WAY)
t=linspace(0,160,1200);
t=t';
 
% applied forces vector (DITTO)
ua1 = ones(1,1200);
ua2 = ones(1,1200);
ua1 = ua1 .* 2;
ua2 = ua2 .* 4;
 
%Simulation using LSIM
sys1=tf(num_11,den);
sys2=tf(num_12,den);
sys3=tf(num_21,den);
sys4=tf(num_22,den);
y1_1=lsim(sys1,ua1,t);
y1_2=lsim(sys2,ua2,t);
y1=y1_1+y1_2;
y2_1=lsim(sys3,ua1,t);
y2_2=lsim(sys4,ua2,t);
y2=y2_1+y2_2;
 
%Plots y1 in green, y2 in red (AGAIN, MY WAY)
figure(1)
 
subplot(2,1,1)
plot(t, y1, 'g')
title('Y1 - displacement')
xlabel('Time (?)')
ylabel('Displacement (?)')
%grid on
 
subplot(2,1,2)
plot(t, y2, 'r')
title('Y2 - displacement')
xlabel('Time (?)')
ylabel('Displacement (?)')
%grid on
 
Last edited:
thanks for the help! what a minor oversight on Cden! that fixed everything (even without the changes you made to other parts of the code. ) i dont know how i missed it. i even went to the TA for the class and she didnt notice either, lol. and units werent defined in the problem, its just for concept i guess, to make sure we can do it.
 
Last edited:
next question, how can i model this in simulink? when i get down to the last 4 scopes (my 4 transfer funtions) i cant seem to get them to add together like i need to.
 
i just now got it :) i thought you had to sum after getting to the scope (which you cant) so i just summed them after the TF and then into the scope and it works :)
 

Attachments

  • screen.jpg
    screen.jpg
    187.5 KB · Views: 84
lol surprised you didnt break the board with that.

"pi is exactly 3!" LOL
 
holy Fuck man! why coudnt you just post another kitten or something :lol:

damn

Ian hope you and Tommy get it. i have no clue what the hell you talking about but good luck
 
should be fixed, i deleted it completely

now onto the "easier" single input systems. ill check back if i have issues.
 
Back
Top