Search code examples
matlabmatlab-figurematlab-guide

Matlab GUIDE uitable remove NaN values


I am reading a excel file and displaying it in uitable in Matlab GUIDE.

Code for reading file and displaying to uitable is

 [num, txt, raw] =  xlsread('D://qq.xls','D1');
 set(handles.uitable1,'visible','on','Data',raw);

Now my file contains all mix data, so I preferred using raw.

After using raw, I am getting all data but also I am getting additional NaN values.I am attaching screenshot enter image description here bottom part of image contains all NaN values.

I have got 2 queries:

  1. How can I replace them with blank values?

  2. Also, how can I replace 1 with Yes and 0 with No?

Please help


Solution

  • s=size(raw);
    for i=1:s(1,1)
        for j=1:s(1,2)
            if strcmp(raw(i,j),'NaN')
                raw(i,j)={' '};
            end
            if isequal(raw(i,j),{1})
               raw(i,j)={'Yes'};
            end
    
            if isequal(raw(i,j),{0})
               raw(i,j)={'No'};
            end
        end
    end