how to use findpeaks in fft (with for,if,else)
조회 수: 6 (최근 30일)
이전 댓글 표시
I did this code on the matlab function simulink with the input is a sine signal with a frequency of 49 and 98, and it was converted into a frequency domain with fast fourier transform with a sampling frequency of 1000 so that the magnitude amplitude value could be up to 1000 more, I used findpeaks to get the peak value and the location of the peaks that appear at frequencies 49 and 98, but in fact there are many small peaks that are read by findpeaks, therefore I use for if and else to only read above the value of 1000, but still not successful with a written error
Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and / or sizes for the block outputs.
is it possible that anyone can help where the error lies, thanks
function [dist,locs1,locs2] = fcn(u)
for i = -500:500
if(u(1,i)>1000)
x = u(1,i);
break;
end
end
[pks,locs] = findpeaks(x);
findpeaks(x);
a = locs(4)- locs(3);
b = locs(3);
c = locs(4);
dist = a;
locs1 = b;
locs2 = c;
댓글 수: 0
답변 (1개)
Chaitanya Mallela
2020년 12월 30일
편집: Chaitanya Mallela
2020년 12월 30일
You can try findpeaks function with Name Value pairs such as 'MinPeaksHeight', 'MinPeakDistance' and 'NPeaks'
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!