How to apply Heaviside function over external force?
3 次查看(过去 30 天)
显示 更早的评论
Dear all,
Suppose we have a harmonic external force in time-domain, and I need to apply this force for only 5 seconds and then get the system response for 100 seconds.
System is defied with all dynamic properties like mass, stuffness and damping ...,
- there is easier way to handle it via Simulink, but we need to script the code in time-domain.
The code we have, applies the external force during the entire time interval which is not our interest. We want to apply the excitation only for a short time interval like 3-5 seconds but not more.
Any ideas?
m = 1; % mass
c1 = 0.5; % damping
k = 1; % stiffness
ccr = 2*sqrt(m*k); % critical damping
zeta1 = c1/ccr; % damping ratio
w = sqrt(k/m); % w stands for natural frequency
%% Bode plot and TF generation
mytf1 = tf([0,01],[1,2*zeta1*w,w^2]) % creating the T.F.
% time-domain
v0 = 0.5; %I.C. in velocity in m/s
y0 = 0.05; % I.C. initial displacement in meteres
t = linspace(0 , 100 , 1000);
wd = w*sqrt(1 - zeta1^2); % damped frequency
yh = exp(-zeta1.*w.*t).*(y0.*cos(wd.*t)+((v0+zeta1.*w.*y0)/wd).*sin(wd.*t));
% define the Harmonic Excitation
we = 0.25
% frequency of the system - Resonance
F0 = 0.1; % F0 is the amplitude of the harmonic excitations in meters
F = F0.*exp(1j.*we.*t);
yp = (F0 ./ (w^2 - we^2 + 2*zeta1*w*we)) .* exp(1j.*we.*t);
y = yh + yp;
figure(2)
plot(t , y , 'b');
hold on
plot(t , yp , 'r');
hold on
plot(t , yh , 'k');
hold off
% set(gca , 'FontSize' , 12)
legend({'both transient and steady-state' , 'steady-state' , 'transient'} , 'FontSize' , 12)
grid on
figure(3)
plot(t , yp)
figure(4)
plot(t , y)
0 个评论
采纳的回答
Walter Roberson
2022-8-31
The laplace of a rectangular pulse can be written like s*(1-exp(-s*h)) where h is the width of the pulse. This can be written s=tf('s') and then the above expression with numeric h value, getting a ss model as a result. Multiply by your tf to get a windowed version of the model.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!