Findpeaks the reason why my index is floating
Show older comments
Hi there,
I have a question about the findpeaks function. To my surprise, my location index is receiving a float, which is causing all of my calculations to be incorrect.
Please assist me in fixing the coding error. Expectation is that the peak value's position should be an integer number.
dctCoef = [8429.999786
2771.087211
607.721985
3118.100821
1112.991245
1013.033319
350.156147
368.204981
822.470058
971.052424
1472.593343
406.350435
893.834342
612.080075
-13.394000
138.237194
61.093121
127.999481
222.903100
313.873293];
minHeigth = mean(round(abs(dctCoef / 2.^8))) + std(round(abs(dctCoef / 2.^8)))*8e-1;
[pks,locs] = findpeaks(round(abs(dctCoef / 2.^8)),20,'MinPeakHeight',minHeigth);
locs
pks
% Manual analysis
fprintf('%20s|%20s|%20s|\n--------------------+--------------------+--------------------+\n', ...
'indx','raw_data', 'scaled_data');
for i = 1:size(dctCoef,1)
fprintf('%20d|%20.6f|%20.6f|\n',i,dctCoef(i), round(abs(dctCoef(i)/ 2.^8)))
end
2 Comments
Life is Wonderful
on 3 May 2023
Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!