0% found this document useful (0 votes)
36 views2 pages

% System Parameters: 'Time, S' 'Position, M'

This document defines parameters for simulating the response of a single-degree-of-freedom mass-spring-damper system excited by a sinusoidal force. It compares the response found using a state-space representation solved with MATLAB's linear system solver versus using an ODE solver. Plots of position and velocity versus time from both methods show good agreement.

Uploaded by

Arif Nurizki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

% System Parameters: 'Time, S' 'Position, M'

This document defines parameters for simulating the response of a single-degree-of-freedom mass-spring-damper system excited by a sinusoidal force. It compares the response found using a state-space representation solved with MATLAB's linear system solver versus using an ODE solver. Plots of position and velocity versus time from both methods show good agreement.

Uploaded by

Arif Nurizki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

clear all

% define simulation parameters


dt=0.001; % time increment, sec
t=0:dt:5; % time vector, sec
y0=[0;0] % initial conditions vector
F0=1.5; % force amplitude, N
w=20; % excitation frequency, rad/s
F=F0*cos(w*t); % excitation function
% system parameters
m=2;
c=3.2;
k=150;

% (1) using state space Matlab solver


A=[0 1; -k/m -c/m]; % state matrix
B=[0;1/m]; % input matrix
C=[1 0;0 1]; % output matrix for position and velocity
D=[0;0] % input feedthrough matrix
sys1=ss(A,B,C,D); % create state space system representation
Y=lsim(sys1,F,t,y0); % simulate the system response

% plot displacement
figure(1)
clf
subplot(2,1,1)
plot(t,Y(:,1))
grid on
xlabel('Time,s')
ylabel('Position, m')
subplot(2,1,2)
plot(t,Y(:,2))
grid on
xlabel('Time,s')
ylabel('Velocity, m/s')

UNTIL THIS GET LIKE IN THE PDF


% (2) using ode45 solver
[T,Yode]=ode45(@(t,z) sdoffile(t,z,F0,w,m,c,k),t,y0);

%
% function that calculates derivatives of the states
%
function [dz]=sdoffile(t,z,F0,w,m,c,k)
dz=[0 1; -k/m -c/m]*z+[0;1/m]*F0*cos(w*t);
figure(1)
%clf
subplot(2,1,1)
hold on
plot(T,Yode(:,1),'r--')
grid on
xlabel('Time,s')
ylabel('Position, m')
hold of
subplot(2,1,2)
hold on
plot(T,Yode(:,2),'r--')
grid on
xlabel('Time,s')
ylabel('Velocity, m/s')
hold of
MEEG

You might also like