Remove Empty Values from a nx1 Vector of doubles

12 views (last 30 days)
R = [1, 2, , 4, 5, , 7, , , , ,12 ];
I would like to remove all the blank values.
I have tried cellfun('isempty') and I get an error that this is only applicable to cells.
I have also tried R = R('isempty')
R = R(~'isempty)
  2 Comments
the cyclist
the cyclist on 27 Mar 2020
Edited: the cyclist on 27 Mar 2020
There cannot be "blank" values in a variable of type double. Can you post functioning MATLAB code that defines what you actually have? (Your code above does not, of course.)
Stephen23
Stephen23 on 27 Mar 2020
"Remove Empty Values from a nx1 Vector of doubles"
All numeric array elements have a value, they cannot be "empty".
If you want help you will have to provide us with actual data or a more accurate description of your data.

Sign in to comment.

Answers (1)

Srivardhan Gadila
Srivardhan Gadila on 30 Mar 2020
An array can't have an empty value. The whole array itself should be empty.
If you are having any NaN, inf then find them using isnan & isinf functions.
You can refer to:
  1. How to write the matrix with blank element?
  2. Assign empty value(s) to matrix elements (to delete those elements) fails
  3. empty
  4. Empty Arrays

Categories

Find more on Numeric Types 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!