Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
89 views

MATLAB Code For Closed Form Solution

This document contains MATLAB code for solving damped and undamped single degree of freedom vibration problems using both closed form and numerical solutions. The code provides the equations of motion, defines parameters, solves for the response, and plots the results. Sections include damped free vibration closed form solution, damped free vibration numerical solution, undamped free vibration closed form solution, and undamped free vibration numerical solution.

Uploaded by

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

MATLAB Code For Closed Form Solution

This document contains MATLAB code for solving damped and undamped single degree of freedom vibration problems using both closed form and numerical solutions. The code provides the equations of motion, defines parameters, solves for the response, and plots the results. Sections include damped free vibration closed form solution, damped free vibration numerical solution, undamped free vibration closed form solution, and undamped free vibration numerical solution.

Uploaded by

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

MATLAB code for damped free vibration closed form solution

m =1; %given data from a problem


k =5;
z =0.05;

x0 =0; %initial conditions


xdot0 =1;

wn =sqrt(k/m); %natural frequency

wd =wn*sqrt(1-z^2) %damped frequency


X1 =x0;
X2 =(xdot0+(z*wn*x0))/wd;
i =1;

alpha =atan(X2/X1); %phase angle


X =sqrt(X1^2+X2^2); %amplitude

for t =0:0.02:15
x(i) =exp(-z*wn*t)*X*cos((wd*t)-alpha);
i =i+1;
end

t =0:0.02:15;

plot(t,x);
grid on;
MATLAB code for damped free vibration numerical solution

m =1; %given data from a problem


k =5;
c=0.223;

wn=sqrt(k/m); %natural frequency


z=c/(2*wn*m); %damping ratio

tol=1e-6; %tolerance value for numerical integration

x0=0; %intitial conditions


xdot0=1;
t=0:0.02:30;
tf=[0 30]; %span for integration
X_IC=[x0 xdot0]; %intitial condition array

[t,y]=ode45(@num_sol,tf,X_IC,tol) %ode solver

x=y(:,1); %displacement

plot(t,x);
grid on;
hold on;

Snippet for function definition

function ydot =num_sol(t,y) %function declaration

m=1; %data from problem


k=5;
c=0.223;

ydot1=y(2); %first order equations


ydot2=-(k*y(1)+c*y(2))/m;

ydot =[ydot1;ydot2]; %2 first orders as array


MATLAB code for undamped free vibration closed form solution

m =1; %data from problem


k =5;

x0=0; %intial conditions


xdot0=1;

wn=sqrt(k/m); %natural frequency

X1=x0;
X2=xdot0/wn;

i=1;

alpha=atan(X2/X1); %phase angle


X=sqrt(X1^2+X2^2); %amplitude

for t=0:0.02:30
x(i)=X*cos((wn*t)-alpha);
i=i+1;
end

t=0:0.02:30;
plot(t,x);
hold on;
MATLAB code for undamped free vibration numerical solution

m =1; %given data from a problem


k =5;

wn=sqrt(k/m); %natural frequency

tol=1e-6; %tolerance value for numerical integration

x0=0; %intitial conditions


xdot0=1;
t=0:0.02:30;

tf=[0 30]; %span for integration


X_IC=[x0 xdot0]; %intitial condition array

[t,y]=ode45(@num_sol,tf,X_IC,tol) %ode solver

x=y(:,1); %displacement

plot(t,x);
grid on;
hold on;

Snippet for function definition

function ydot =num_sol(t,y) %function declaration

m=1; %data from problem


k=5;

ydot1=y(2); %first order equations


ydot2=-k*y(1)/m;

ydot =[ydot1;ydot2]; %2 first orders as array

You might also like