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);
댓글 수: 0
채택된 답변
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.
"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).
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!