Removing nan values inside cells of a cell array
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
johndoe
el 14 de Abr. de 2020
Comentada: Abdulaziz Abutunis
el 19 de Ag. de 2021
I have a cell array that looks like this:

Cells in column 1 would look similar to this with nan values mixed values of salinity:

Column 2 is depth values from 1 and onwards, like this:

Is there any way to remove the nan values in column 1 and the corresponding values in column 2?
I've been trying to search for it but haven't found a way that I could get to work.
0 comentarios
Respuesta aceptada
Geoff Hayes
el 14 de Abr. de 2020
Jaskabara - you can use isnan to determine which elements are NaN in your array. This function returns a logical array containing 1 (true) where the elements of A are NaN, and 0 (false) where they are not. For example,
column1 = randi(255,15,1); % generate two 15x1 columns of random integers
column2 = randi(255,15,1);
column1(5) = NaN; % set a couple of elements in column1 to NaN
column1(11) = NaN;
nanElements = isnan(column1); % determine indices corresponding to NaN elements
column1(nanElements) = []; % remove NaN elements from column1
column2(nanElements) = []; % remove corresponding elements from column2
2 comentarios
Abdulaziz Abutunis
el 19 de Ag. de 2021
This answer is not relevant to the question., The quesion asked to remove NaN from cell array
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!