Why does MATLAB 6.5 (R13) not export NaN or Inf data types properly when used as an ActiveX client?

4 views (last 30 days)
I am using MATLAB 6.5 (R13) as an ActiveX client to connet to Excel. I am trying to export a matrix created in MATLAB which has some of its elements as NaN's or Inf. When I export this matrix to Excel, the NaN's and Inf's get replaced by a number, 65535. I would like to know if NaN and Inf can be replaced by empty elements when exported by MATLAB activex client.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Jul 2010
This change has been incorporated into the documentation in Release 2010a (R2010a). For previous releases, read below for any additional information:
As of MATLAB 7.0 (R14), the expected behavior is that Inf is exported as 65535 and NaN as an empty.
To export Inf as Inf, it must be exported as a string to Excel which implies that the double matrix must be converted to a cell array. See the below example:
% create a matrix with elements equal to Inf
a = floor( rand(10)*10 )
a(find(a == 1)) = Inf
% convert the matrix to a cell array
acell = num2cell(a);
% convert the cells to strings
astr = cellfun(@num2str, acell, 'UniformOutput', false);
xlswrite('temp.xls', astr)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!