Delete specific numbers from cell array
Show older comments
I have a 1801 x 20 data matrix where one column is one set of data. I need to calculate the log diff and I I actually wanted to clear each column from the zeros, but each column has a different amount of zeros within the data (which is not possible in a matrix). I did this so far:
p3=num2cell(p2) ;
p3(p3==0)=[];
or:
p3(cellfun(@(p3==0)=[];
But both didnt work.
2 Comments
Mathieu NOE
on 18 Nov 2020
hello Marie
why converting to cell array ? the test can be done directly on the nimeric data , column wise
regards
Marie P.
on 18 Nov 2020
Accepted Answer
More Answers (1)
p2 = [1, 2; 0, 1]
p3 = num2cell(p2, 1);
Wanted = cellfun(@nonzeros, p3, 'un', 0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!