there are more than 1 element satisfy the command in one column, but I only need to count it one time
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
YU-HAN LIAO
il 18 Ago 2019
Commentato: Star Strider
il 18 Ago 2019
hello, experts,
I am new to Matlab community and a beginer to use it
I have a dataset (refer as attachment)
data = textread('January-2018-Adelaide.csv', '', 'headerlines', 1, 'delimiter', ',');
and would like to count how many days satisfy the cammand
which is the temerature exceed 41.0
however, in some days, there are more than one temerature exceed 41.0
and if i use
n_days_above = numel(find(temperatures>41));
it will be count more than one time (it shows: n_days_above =7, but the correct answer is 3 )
how can I solve this problem?
thank you in advanced!
data = textread('January-2018-Adelaide.csv', '', 'headerlines', 1, 'delimiter', ',');
temperatures = data(:, 4:end);
n_days_above = numel(find(temperatures>41));
0 Commenti
Risposta accettata
Star Strider
il 18 Ago 2019
Try this:
maxTemp = max(data(:,4:end),[],2);
Above41 = nnz(maxTemp > 41)
producing:
Above41 =
3
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!