Replace nan's with blanks

Asked by Matthew on 11 Jul 2012
Latest activity Commented on by Matthew on 11 Jul 2012

I am having a problem with trying to export data to excel using actxserver. The vector I have in matlab has NaN's in it and I want them to show up as blanks in excel but they always show up as the value 65535. How can I replace the NaN's in matlab so that they are blanks. For example if I have a 1x1 matrix A which contains a bunch of numbers and NaN's I want to turn the NaNs into blanks. I tried something like this

B = num2cell(A);
B(isnan(B))=[];

but I get this error Undefined function 'isnan' for input arguments of type 'cell'.

I also tried

A(isnan(A))=[];

This deleted the Nan's and shortened the matrix, but I need a matrix of equal size with blank spaces int eh middle.

I have seen others try to turn NaNs into zero's on forums but that does not work for me because zeros would look like good data in the excel file not missing values.

1 Comment

Ryan on 11 Jul 2012

I believe that matrices in matlab require some value to fill each slot. I think that cell arrays allow for empty cells though.

Matthew

Products

No products are associated with this question.

1 Answer

Answer by Honglei Chen on 11 Jul 2012
Edited by Honglei Chen on 11 Jul 2012
Accepted answer
B(cellfun(@isnan,B)) = {[]}

1 Comment

Matthew on 11 Jul 2012

Thanks.

Honglei Chen

Contact us