Remove Empty Values from a nx1 Vector of doubles

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

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.)
"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)

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

Asked:

on 27 Mar 2020

Answered:

on 30 Mar 2020

Community Treasure Hunt

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

Start Hunting!