I am using findpeaks (data,locations) func to find time period of trigonometric function. Values(max,location) for only one peak are getting stored, hence time period is coming out to be zero. please help.

조회 수: 2 (최근 30일)
m= 750; % mass of the system in kg
k= 50000; % Stiffness of system in N/m
c= 1000; % damping coefficient Ns/m
time= 0:0.01:1; %time in sec
x_0=0.01; % displacement intial condition
x_dot_0=0;
syms x(t)
D1x= diff(x,1); % differentiation
D2x= diff(x,2);
x= dsolve(m*D2x+k*x==0,x(0)==x_0, D1x(0)==x_dot_0,'t');
x_fun=matlabFunction(x) % to save solved function values
x_dot_fun = matlabFunction(diff(x));
x_t=x_fun(time);
[maxima,maxima_location]= findpeaks(x_t,time);
time_period= diff(maxima_location);

채택된 답변

Luuk van Oosten
Luuk van Oosten 2019년 6월 5일
Dear Abhijeet,
I am not sure what you mean with "hence time period is coming out to be zero", but I do believe I can be of some assistance:
If you plot your signal
plot(time, x_t)
You will see that there seem to be two peaks, one at time point zero and one at time point 0.77.
But... If you use findpeaks, the documentation states that it finds local peaks, but only if
"a data sample that is either larger than its two neighboring samples or is equal to Inf. Non-Inf signal endpoints are excluded."
I believe in your case it does not come up with the local maxima at time=0, due to that reason (if that is what you mean).
  댓글 수: 1
Abhijeet Vishwasrao
Abhijeet Vishwasrao 2019년 6월 6일
thank you for your answer....it helped a lot. Previously as I was getting only one maxima_location (0 was excluded as you rightly said) so time period was a null matrix(as it is difference between 2 maxia_locations). Now i just increased 'time' and it helped.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by