Removing nan values inside cells of a cell array
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Geoff Hayes
2020-4-14
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 个评论
Abdulaziz Abutunis
2021-8-19
This answer is not relevant to the question., The quesion asked to remove NaN from cell array
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!