Find zeros in a large table and replace with average of two previous column values
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I have a fairly big table that I've imported from excel (11201x136). The first column is essentially a time series in seconds and the remaining 135 columns are different sets of data. For some columns, there is missing data which is pulling as NaN and this is fine as I don't need to use these columns. However, there are other columns where some of the data has not recorded properly and therefore some values are zero. What I am looking to do is find and replace those zero values across each column with an average of the two previous readings but I'm pretty new to matlab and struggling to write the correct code. I can't attach the data I'm afraid as it is confidential.
I've loaded the data as a table as the first column is hh mm ss which doesn't seem to work with xlsread (example below):
Data = readtable('Data.xls', 'sheet', 'Rawdata')
Correcting the zeros is the first thing I need to do but unfortunately it seems more difficult than I anticipated...
Any help is much appreciated,
0 commentaires
Réponses (1)
KSSV
le 26 Jan 2022
You can find the zeros using logical indexing or the functon find. Replace those 0 values with NaN and then use the function fillmissing. Read about fillmissing.
5 commentaires
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!