% In class 8-April-08 fprintf('The date and time: %s \n', datestr(now))
The date and time: 08-Apr-2008 13:33:16
% Should be able to solve DE's in MATLAB domain and in the Simulink % domain. % % Will not have to generate equations from a model. Equations will be % given. % % Applications in Vibrations/Controls % % Ex: Mass-Spring-Damper system % % Given: spring of stiffnes k, a damper with damping constant C, The % spring and damper support a plate with mass m hanging from the % celing. f(t) = forcing function % % To analyze the system, apply Newton's second law: sum(F) = ma. % % In the dynamic condition: % the second order differentil equation that represents the % system is: m*y'' + c*y' + k*y = f(t) ... (2) % % To obtain a solution using Simulink we must express (2) in the % Laplace domain. Assume initial conditions are zero! % ms^2Y(s) + csY(s) + kY(s) = F(t) ... (3) % % also rewrite (3) in the input/output format. % Y(s) = F(t)/(ms^2 + cs + k) ... (4) % % In characteristic form, make the coefficient of the "s^2" term % unity (i.e. 1). % Y(s) = ((1/m)/(s^2 + (c/m)s + k/m))*F(s) ... (4) % % Get transfer function (T.F.): % T.F.'s are used in simulink % T.F. = coefficient of F(s) % Y(s) = (T.F.)*F(s) % T.F. = ((1/m)/(s^2 + (c/m)s + k/m)) ... (5) % % Solve system using simulink % Suppose: m = 5 kg, k = 500 lcg/s^s, c = 20, % f(t) = step function % Set these values in the MATLAB domain. % Be sure to run MATLAB before running the simulink % simulation! % % See 1. Mass-Spring-Damper system % % Simulink: % % Create a step function, a transfer function, and a scope. % Link all three together and put the T.F. in the transfer function % block. % % For real time anallysis: % double-click scope % > click Parameters % >> click Save data to workspace % >>> give variable a name and format as an array. % %
fprintf('The date and time: %s \n \n', datestr(now)) disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('% %') disp('% Purpose: Solve a Mass-Spring-Damper system %') disp('% %') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') % Load variables in the workspace to be used in the simulink model m = 5; % mass k = 500; % spring stiffness c = 20; % damping constant % Creat and run the Simulink modual: Mass_Spring_Damper_system.mdl whos % find the variable created in simulink (I named MassSpringDamping). plot(MassSpringDamping(:,1), MassSpringDamping(:,2)), xlabel('t'), ... ylabel('f(t)'), title('f(t) = m*d_2y/dt_2 + c*dy/dt + k*y'), ... grid
The date and time: 08-Apr-2008 13:33:16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Purpose: Solve a Mass-Spring-Damper system % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name Size Bytes Class MassSpringDamping 62x2 992 double array c 1x1 8 double array k 1x1 8 double array m 1x1 8 double array tout 62x1 496 double array Grand total is 189 elements using 1512 bytes
Simulink Model: