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

Dai Nguyen
Dai Nguyen 2021년 2월 23일
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 2021년 2월 23일
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 2021년 2월 23일
opps sorry here is my excel. Thank so much for your time
Dai Nguyen
Dai Nguyen 2021년 2월 23일
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 2021년 2월 23일
Thank you so much
Star Strider
Star Strider 2021년 2월 23일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2021년 2월 23일

댓글:

2021년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by