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=

回答(1 个)

Star Strider
Star Strider 2021-2-23

1 个投票

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

7 个评论

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!
.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by