I have a small function that finds the peaks in a matrix and then replacing it by 0. The end output is related to the columns. I'm having hard time fixing the syntax to make it work the same way but for the rows as well. Any ideas ? Here's the code :
HVAzimuthFreqAbs = abs(HVAzimuthFreq);
M = HVAzimuthFreqAbs;
for k1 = 1:size(M,1)
[pks,loc] = findpeaks(M(k1,:),'Threshold',150);
P{k1} = [pks; loc];
end
HVAzimuthFreq(:,loc) = 0;
The main key as I understand is to switch between the order that the size refers to, but I have no luck in doing that. For example -
for k1 = 1:size(1,M)
[pks,loc] = findpeaks(M(:,K1),'Threshold',ThresholdUpper);
P{k1} = [pks; loc];
end
is giving me an 'Dimension argument must be a positive integer scalar within indexing range' error.
Any ideas ? thanks
findpeaks(M(:,K1).','Threshold',ThresholdUpper);
work for you? – Ander Biguri