Plot and calculate Damping ratio

Hi I want to calculate damping ratio by using the log decrement method, but for my understanding we need to select 2 peaks in order to do it. Can matlab do it by itself ?or I have to do it manually. Here is what I got so far.
[v,T,vT]=xlsread('Velocity_Response_of_Pendulum.xlsx')
Time=v(:,1);
Veloc=v(:,2);
xlabel('Time');
ylabel('Velocity');
plot(Time,Veloc);
%pick the first peak (t,v) (0.372,0.02884)
%pick the 2nd peak (1.826, 0.02883)
damp_ratio=

Answers (1)

Star Strider
Star Strider on 23 Feb 2021
The findpeaks or islocalmax functions can return the information to do the calculations.

7 Comments

I see but since I import the data from excel what will be the format for findpeaks. Is it pks=findpeark(Time, Veloc)?
I have no idea what is in your Excel file.
Read it using readmatrix, then follow the instructions relevant to it in the documentation I linked to.
opps sorry here is my excel. Thank so much for your time
I rewrite the code but for some reason it didn't highlight the peaks
A=xlsread('Velocity_Response_of_Pendulum.xlsx');
time=A(:,1);
veloc=A(:,2);
plot(time,veloc)
[pks,locs]=findpeaks(A,time);
Try this:
T1 = readtable('Velocity_Response_of_Pendulum.xlsx');
[pks,locs] = findpeaks(T1.velocity, 'MinPeakProminence',1E-2);
exp_dk = @(b,x) b(1).*exp(b(2).*x);
B = fminsearch(@(b) norm(T1.velocity(locs) - exp_dk(b,T1.time(locs))), rand(2,1).*[1;-1]);
figure
plot(T1.time, T1.velocity)
hold on
plot(T1.time(locs), T1.velocity(locs), '^r', 'MarkerFaceColor','r')
plot(T1.time, exp_dk(B,T1.time), '-g', 'LineWidth',1.5)
hold off
grid
ylabel('Amplitude')
xlabel('Time')
title(sprintf('$y(t) = %.4f\\cdot e^{%.6f\\cdot t}$',B), 'Interpreter','latex')
producing:
.
Thank you so much
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

Categories

Products

Release

R2020a

Asked:

on 23 Feb 2021

Commented:

on 23 Feb 2021

Community Treasure Hunt

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

Start Hunting!