how to count a sequence of data arrays with cut off?
Mostra commenti meno recenti
i have 5 data in one array. For example, the data array [2.33 2.00 1.60 1.59 1.99]. If the cutoff is 1.50, it means the amount of data is 4 (pay attention to the order of the data). the number 1.99 in the 5th index is not counted.
This is my code
cnr_all=[2.33 2.00 1.60 1.59 1.99];
cut_off=1.50;
N=zeros(size(cnr_all));
for i=1:numel(cnr_all)
if cnr_all[i] >= cut_off;
N=N+1;
break;
end
end
disp(N)
5 Commenti
Pratyush Swain
il 16 Mag 2024
Hi Rahmat,
Can you explain why the 5th index element(1.99) is not included ? Because the first four elements are also greater than the cut off. Can you explain clearly how does this cutoff workflow/method work ?
% e.g. array
cnr_all=[2.33 2.00 1.60 1.45 1.99];
% cut-off
cut_off=1.50;
N=0;
for i=1:numel(cnr_all)
if cnr_all(i) >= cut_off;
N=N+1;
%break; %comment the break
end
end
disp(N)
rahmat
il 16 Mag 2024
rahmat
il 16 Mag 2024
rahmat
il 16 Mag 2024
Risposta accettata
Più risposte (1)
hello
why not simply this ?
% example 1
cnr_all=[2.33 2.00 1.60 1.59 1.99];
cut_off=1.50;
[~,N] = min(cnr_all - cut_off)
% example 2
cnr_all=[2.33 2.00 1.60 1.51 1.53];
cut_off=1.50;
[~,N] = min(cnr_all - cut_off)
5 Commenti
rahmat
il 16 Mag 2024
rahmat
il 16 Mag 2024
Mathieu NOE
il 16 Mag 2024
well, I believed I understood yor goal - as you described above
because I want a trend in the data. For example, there is data from the largest to the smallest (cutoff), but after the smallest data (cutoff) there is data that exceeds the cutoff value. This data is ignored.
but what would you expected in this new case ?
%example array
data_array = [2.33, 2.00, 1.60, 1.59, 1.99];
% Cutoff value
cutoff_value = 2.00;
rahmat
il 16 Mag 2024
Mathieu NOE
il 16 Mag 2024
ok - still I'd like to have from you what then is expected in that case :
%example array
data_array = [2.33, 2.00, 1.60, 1.59, 1.99];
% Cutoff value
cutoff_value = 2.00;
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!