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=

Réponses (1)

Star Strider
Star Strider le 23 Fév 2021

1 vote

The findpeaks or islocalmax functions can return the information to do the calculations.

7 commentaires

Dai Nguyen
Dai Nguyen le 23 Fév 2021
I see but since I import the data from excel what will be the format for findpeaks. Is it pks=findpeark(Time, Veloc)?
Star Strider
Star Strider le 23 Fév 2021
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.
Dai Nguyen
Dai Nguyen le 23 Fév 2021
opps sorry here is my excel. Thank so much for your time
Dai Nguyen
Dai Nguyen le 23 Fév 2021
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:
.
Dai Nguyen
Dai Nguyen le 23 Fév 2021
Thank you so much
Star Strider
Star Strider le 23 Fév 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2020a

Question posée :

le 23 Fév 2021

Commenté :

le 23 Fév 2021

Community Treasure Hunt

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

Start Hunting!

Translated by