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.

1 回表示 (過去 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 Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by