0% found this document useful (0 votes)
49 views

Assignment 2 Viscous Damping

The document contains MATLAB code to model viscous dampers in mechanical vibrations, showing the code for defining system parameters like mass and spring constant, solving the differential equation describing the system using ode45, and plotting the displacement, velocity, and acceleration outputs over time for undamped, underdamped, critically damped, and overdamped cases with different parameters. It was submitted by Muhammad Tayyab, roll number 035 from the BSME 2020-24 batch, to Dr. Zahid Iqbal for Assignment #2 on viscous dampers in mechanical vibrations.

Uploaded by

Muhammad Tayyab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Assignment 2 Viscous Damping

The document contains MATLAB code to model viscous dampers in mechanical vibrations, showing the code for defining system parameters like mass and spring constant, solving the differential equation describing the system using ode45, and plotting the displacement, velocity, and acceleration outputs over time for undamped, underdamped, critically damped, and overdamped cases with different parameters. It was submitted by Muhammad Tayyab, roll number 035 from the BSME 2020-24 batch, to Dr. Zahid Iqbal for Assignment #2 on viscous dampers in mechanical vibrations.

Uploaded by

Muhammad Tayyab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mechanical Vibrations

Assignment # 2

MATLAB Code for Viscous Dampers

Submission Date: 20-11-2023

Name: Muhammad Tayyab

Roll No 035

Batch: BSME 2020-24

Submitted To Dr. Zahid Iqbal


MATLAB Code
% Define the system parameters
clear all
clc
m = input('inter mass= '); % Mass
% c = 1; % Damping coefficient
k = input('Spring Constant= '); % Spring constant
zeta=input('Zeta Value= ');
natural_frequency=(k/m)^0.5;
c_c=2*m*natural_frequency;
c=c_c*zeta;
natural_frequency=(k/m)^0.5
x0 = 2; % Initial displacement
x_dot0 = 0; % Initial velocity

% Create a function representing the differential equation


% dxdt = x_dot
% dx_dotdt = -c/m * x_dot - k/m * x
ode = @(t, y) [y(2); -(c/m) * y(2) - (k/m) * y(1)];

% Time span for the simulation


tspan = [0 10]; % Adjust the time span as needed

% Solve the ODE using ode45


[t, y] = ode45(ode, tspan, [x0, x_dot0]);

% Extract displacement, velocity, and acceleration


x = y(:, 1); % Displacement
x_dot = y(:, 2); % Velocity
x_double_dot = -(c/m) * x_dot - (k/m) * x; % Acceleration

% Plot displacement, velocity, and acceleration


figure;
%subplot(3,1,1);
plot(t, x, 'g-', 'LineWidth', 2, 'DisplayName', 'Displacement');
title('Displacement vs Time');
xlabel('Time');
ylabel('Displacement');
hold on
%plot(3,1,2);
plot(t, x_dot, 'r-', 'LineWidth', 2, 'DisplayName', 'Velocity');
title('Velocity vs Time');
xlabel('Time');
ylabel('Velocity');
%subplot(3,1,3);
hold on
plot(t, x_double_dot, 'b-', 'LineWidth', 2, 'DisplayName', 'acceleration');
title(' acceleration, Velocity and displacement vs Time');
legend('show');
xlabel('Time');
ylabel('Acceleration, Velocity and Displacement');
Undamped
m=2 kg
k=2 N/m
Zeta=0

Underdamped
m=1 kg
k=2 N/m
Zeta=0.3
Critically Damped
m=3 kg
k=2 N/m
Zeta=1

Overdamped
m=2 kg
k=3 N/m
Zeta=2

You might also like