I need to leave values in an array in blank. NaN problem
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Patricia Alejandra Palacios Romero
il 15 Mag 2018
Commentato: Patricia Alejandra Palacios Romero
il 24 Mag 2018
Im working with data that should follow some restrictions, for example the water level in a tank is measured in % so it cannot be more than 100, however, due to measurement erros it can be the case that the measurement mark 120 for example. How should I work with this data if I don't want wrong data to mess up further statistic calculations?. Is it correct to leave the data in blank? and if so what should the condition: NaN? Thank you for your help!
0 Commenti
Risposta accettata
Alfonso
il 15 Mag 2018
If you are saving all the water level values in an array 1xn or nx1 (a row or column vector) , you could delete the incorrect values retreived like this
i=1;
While i<length(data_array) % Recorremos array con valores de nivel de agua
if data_array(i)>100 % si es mayor al max se elimina
data_array(i) = [] ; %vaciamos/eliminamos el valor
end
i=i+1;
end
5 Commenti
Guillaume
il 17 Mag 2018
I recieved an error message in this part of the code:
Your implementation has the same issue as Alfonso's algorithm. Your i will become out of sync with the actual rows once you've deleted something. In addition, you're trying to delete a single element in a row of a matrix, which is not possible. What you want to do is to delete the whole row.
The efficient and safe way to do that in matlab:
B = A;
B(any(B(:, [5, 20, 23]) > qin250, 2), :) = []; %delete all rows for which any of column 5, 20 or 23 is greater than qin250
Più risposte (1)
Steven Lord
il 17 Mag 2018
If you use NaN or missing (which for numeric arrays are the same thing) to represent the missing data in your data set, you can use some of the functions designed for handling missing data to remove, replace, or perform computations ignoring the missing data.
0 Commenti
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!