Replace 32767 with NaN in entire table

12 visualizaciones (últimos 30 días)
Marcel345614
Marcel345614 el 26 de En. de 2022
Comentada: Marcel345614 el 27 de En. de 2022
I have a timetable with some strange values(32767 (probably Inf)) in all columns of my table.
How can I replace all these with NaN's ?
I tried the following, but it didn't work:
% Method 1
Data(Data==32767)=NaN;
%Method 2
for j=1:size(Data,2)
Data(Data(:,j)==32676,j)=NaN;
end

Respuesta aceptada

ANKUR KUMAR
ANKUR KUMAR el 26 de En. de 2022
Editada: ANKUR KUMAR el 26 de En. de 2022
You can get the table in a matrix form using .Variables. Once you have a matrix, then you can use boolean to replace any numbers with nan. Here is an example of replacing 48.9 with nan.
load outdoors
tt=outdoors(1:5,:);
mat = tt.Variables;
mat(mat==48.9) = nan;
tt.Variables = mat
tt = 5×3 timetable
Time Humidity TemperatureF PressureHg ___________________ ________ ____________ __________ 2015-11-15 00:00:24 49 51.3 29.61 2015-11-15 01:30:24 NaN 51.5 29.61 2015-11-15 03:00:24 NaN 51.5 29.61 2015-11-15 04:30:24 48.8 51.5 29.61 2015-11-15 06:00:24 48.7 51.5 29.6
  3 comentarios
ANKUR KUMAR
ANKUR KUMAR el 26 de En. de 2022
See the updated code.
Marcel345614
Marcel345614 el 27 de En. de 2022
Thanks a lot! Now this was helpful ;-)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by