how to get numerical values as well as texts in a single matrix after reading data from a excel file ?

[num,txt]=xlsread(filename,sheet) here num contains all numerical value and nan (not a number)and txt contains all the texts.now ,how can i replace these nan elements in num by the elements of txt?

 Accepted Answer

The easiest way (not having your file to test this on) is to add a third output to xlsread:
[num,txt,raw]=xlsread(filename,sheet)
The ‘raw’ output should have everything just as the function imported it.

3 Comments

thank u. but what should i do if i have to replace all the nan with blank spaces. i used c(cellfun(@isnan,c))={[]}; but got an error.
i just found how to do it
for k = 1:numel(C)
if isnan(C{k})
C{k} = '';
end
end
this works. thank u

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!