Replace nan's with blanks

조회 수: 22 (최근 30일)
Matthew
Matthew 2012년 7월 11일
댓글: BingoIngo 2019년 5월 15일
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
Ryan
Ryan 2012년 7월 11일
I believe that matrices in matlab require some value to fill each slot. I think that cell arrays allow for empty cells though.

댓글을 달려면 로그인하십시오.

채택된 답변

Honglei Chen
Honglei Chen 2012년 7월 11일
편집: Honglei Chen 2012년 7월 11일
B(cellfun(@isnan,B)) = {[]}
  댓글 수: 3
Rebecca Tharp
Rebecca Tharp 2016년 5월 5일
This leaves a [] in each cell. I get errors when trying to sum (or do other math) on the cells in this case. What can I put in each cell that will be invisible to the program and not change the size and shape of my array?
BingoIngo
BingoIngo 2019년 5월 15일
I have the same issue. Is there a solution for it?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Nemanja Rakicevic
Nemanja Rakicevic 2015년 11월 24일
I had the same issue. I just casted the variable to double instead of single and it returns blank spaces instead of 65535's.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by