How can I use lsim for a constant value input signal

3 views (last 30 days)
I'm needing to plot displacement response with 3 different forcing functions and I'm having trouble getting the forcing function f(t) = 6 to work. I'm also having problems with my time vector as you'll see my code has it commented out(that's the only way I can get it to work for my other two functions), but that's another issue.
%%%%Assign variable values
m1=10; %kg
m2=4; %kg
k1=10; %N/m
k2=15; %N/m
k3=4; %N/m
c=2.4; %N-s/m
%
%%%%Assign transforms for X1(s) & X2(s) that were computed by hand
x1s = (m2*s^2+c*s+k3+k2)/(m1*m2*s^4+m1*c*s^3+(m1*k3+m1*k2+m2*k1+m2*k2)*s^2+(k1*c+k2*c)*s+k1*k3+k1*k2+k2*k3);
x2s = k2/(m1*m2*s^4+m1*c*s^3+(m1*k3+m1*k2+m2*k1+m2*k2)*s^2+(k1*c+k2*c)*s+k1*k3+k1*k2+k2*k3);
% Set transfer function LTI objects by brute force
sys1 = tf([0 0 4 2.4 19],[40 24 290 60 250]);
%free resonse x1 = (4*s^2 + (2.4*s) + 19)/(40*s^4 + 24*s^3 + 290*s^2 + 60*s + 250)
sys2 = tf([0 0 0 0 15],[40 24 290 60 250]);
%free resonse x2 = 15/(40*s^4 + 24*s^3 + 290*s^2 + 60*s + 250)
%%%%%Assign forcing functions
f1=(-2*t);
f2=(6);
f3=cos(3*t);
%%%%%%%%%
% PLOT
%%%%%%%%%
figure;
%%%%%Plot X1(s)/F1(s) & X2(s)/F1(s)
subplot(3,1,1);
%t=0:0.01:10;
z=lsim(sys1,f1,t);
plot(t,z);
title('X1(s)/F(s)& X2(s)/F(s) with f(t)=(-2t)');
xlabel('time (s)');
ylabel('Amplitude');
hold on;
% t=0:0.001:0.1;
z=lsim(sys2,f1,t);
plot(t,z);
hold off;
%
%%%%%Plot X(s)/F2(s) & X2(s)/F2(s)
subplot(3,1,2);
%t=0:0.01:10;
z=lsim(sys1,f2,t);
plot(t,z);
title('X1(s)/F(s)& X2(s)/F(s) with f(t)=(6)');
xlabel('time (s)');
ylabel('Amplitude');
hold on;
% t=0:0.001:0.1;
z=lsim(sys2,f2,t);
plot(t,z);
hold off;
%
%%%%%Plot X1(s)/F3(s) & X2(s)/F3(s)
subplot(3,1,3);
%t=0:0.01:10;
z=lsim(sys1,f3,t);
plot(t,z);
title('X1(s)/F(s)& X2(s)/F(s) with f(t)=cos(3t)');
xlabel('time (s)');
ylabel('Amplitude');
hold on;
% t=0:0.001:0.1;
z=lsim(sys2,f3,t);
plot(t,z);
hold off;

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 22 Apr 2016
Edited: Azzi Abdelmalek on 22 Apr 2016
you said your signal is a constant 6 for example, then for each instant t, the value of your signal is equal to 6. If t=[0 1 2 3], the value of your constant signal should be [6 6 6 6] and not just 6
f2=6
z=lsim(sys2,f2*ones(size(t)),t);

More Answers (0)

Categories

Find more on Control Systems in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!