How to compare a value to a matrix and repeat the comparison after increasing the value
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Ahmed Makki
il 13 Giu 2020
Commentato: Ahmed Makki
il 17 Giu 2020
I am working on an algorithm that compare the vectors' peak locations with the average vector peak location and excluding vectors that their peaks are located over 10 Hz away from the average vector. The average vector peak then it will be included otherwise if the number of vectors included is less than 20 vectors then I should increase the difference in peak location by 10 Hz until it reaches or exceeds 20.
I am not able to create a loop that recompare (RA is the difference between peak locations in Hz) the peaks after increasing V from 10 Hz by 10 Hz every time until the number of vectors I1>=I.
Can you please help me create a loop the recompare RA with V (for k = find(RA<=V))
V=10; I=20; I1=0;
for k = find(RA<=V);
if numel(k)>=I
RI=RV(:,k); I1=numel(k);
elseif I1<I
V=V+10;
else
break;
end
end
end
2 Commenti
Anmol Dhiman
il 16 Giu 2020
Hi Ahmed,
Could you explain the problem statement more clearly and what the variables represent in the code as I am not able to understand the problem clearly.
Risposta accettata
Anmol Dhiman
il 17 Giu 2020
Hi Ahmed,
Based on your explaination
while(1)
% find number of elements that satisfy [array]<=B
numOfElements = length(find(array<=B));
% Check if they are greater than A
if(A<=numOfElements)
y=x+1;
break;
else
B=B+1;
end
end
Più risposte (1)
Steven Lord
il 16 Giu 2020
Do you want to find the candidate peaks using islocalmax then select those candidates that are within 10 of your average?
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!