MAE 143A: Homework 4 Solutions

MAE 143A: Homework 4 Solutions
Jacob Huffman and Elena Menyaylenko
Date Due: February 5th , 2013
Problem 1:
(a)
Duffing Equation.
ẍ(t) + δ ẋ(t) + βx(t) + αx(t)3 = γ cos(ωt)
Matlab Code for duffing.m:
function ydiff=duffing(t,y)
%Function duffing() for simulation of the Duffing oscillator, a nonlivear
%system with sinusoidal excitation
%Local parameters
alpha=1;
beta=-1;
gamma=0.3;
delta=0.2;
omega=1;
%State vector is [y(t); ydot(t)];
dydt=[y(2); -delta*y(2)-beta*y(1)-alpha*(y(1)ˆ3)+gamma*cos(omega*t)];
ydiff=dydt;
return
(b)
Mathieu Equation.
ẋ(t) + [a − 2 cos(2t)]x(t) = 0.
Matlab Code for mathieu.m:
function ydiff=mathieu(t,y);
%function mathieu() for simulation of mathieu equation using ode45
%parameter values
1
a=0.3;
q=0.1;
%state vector is [y(t);ydot(t)]
dydt=[y(2); -(a-2*q*cos(2*t))*y(1)];
ydiff=dydt;
return
Since the mathieu equation is linear, with zero input and zero initial conditions, the
solution will be zero!
Here is the Matlab code to call the functions:
% Hwk Question 1
% part (a), calling duffing function
figure(1)
subplot(1,2,1)
[t,y]=ode45(@duffing,[0,100],[0;0]);
plot(t,y);shg
title (’Duffing: \alpha=1,\beta=-1,\gamma-0.3, \delta=0.2,\omega=1’)
xlabel (’time(sec)’);ylabel(’solution & its derivative(units/time)’);
legend(’signal’,’signal derivative’)
subplot(1,2,2)
% part (a), calling mathieu function
[t,x]=ode45(@mathieu,[0,20],[1;1]);
plot(t,x);shg
hold on
[t,x1]=ode45(@mathieu,[pi/2,20],[1;1]);
plot(t,x1,’k’);shg
title (’Mathieu: \alpha=0.3,q=0.1’)
xlabel (’time(sec)’);ylabel(’solution & its derivative(units/time)’);
legend(’signal’,’signal derivative’)
hold off
2
Duffing: α=1,β=−1,γ−0.3, δ=0.2,ω=1
Mathieu: α=0.3,q=0.1
1.5
2.5
2
solution & its derivative(units/time)
solution & its derivative(units/time)
1
0.5
0
−0.5
−1
1.5
1
0.5
0
−0.5
−1
−1.5
−2
−1.5
0
20
40
60
time(sec)
80
−2.5
signal
100
0
signal derivative
5
10
time(sec)
Figure 1: Duffing and Mathieu Plots
Problem 2:
y(t) = h(t) ∗ u(t)
Z ∞
=
h(τ )u(t − τ ) dτ
−∞
Z ∞
=
u(τ )h(t − τ ) dτ = u(t) ∗ h(t), [Proved on midterm]
−∞
Z ∞
=
cos(ωτ )1(τ )e−(t−τ ) 1(t − τ ) dτ ,
−∞
t
Z
cos(ωτ )e−(t−τ ) dτ , [Proved on midterm]
0
Z t
−t
=e
eτ cos(ωτ ) dτ ,
0
1
et
−t
√
=e
cos (ωt − atan2(ω, 1)) − √
cos (−atan2(ω, 1)) ,
1 + ω2
1 + ω2
−t
1
e
=√
cos (ωt − atan2(ω, 1)) − √
cos (−atan2(ω, 1))
1 + ω2
1 + ω2
=
As t → ∞ y(t) →
√ 1
1+ω 2
cos (ωt − atan2(ω, 1))
3
15
20
Gain Plot
Magnitude(dB)
0
−20
−40
−60
−80
−3
10
−2
10
−1
0
10
10
1
10
2
10
3
10
Phase Plot
Phase(deg)
0
−50
−100
−3
10
−2
10
−1
10
0
1
10
10
Frequency (rad/s)
Figure 2: Bode Plot
4
2
10
3
10
Matlab Code for question 2:
% Hwk Question 2
figure(2)
title(’Bode Plot’)
w=logspace(-3,3);
gain=1./sqrt(1+w.ˆ2);
phase=(-atan2(w,1))*180/pi;
subplot(2,1,1)
semilogx(w,20*log10(gain))
ylabel(’Magnitude(dB)’);
title(’Gain Plot’)
subplot(2,1,2)
semilogx(w,phase)
xlabel (’Frequency (rad/s)’);ylabel(’Phase(deg)’);
title(’Phase Plot’)
%to check
figure(3)
H=tf([1],[1 1])
bode(H)
5