Problem with strings and numerics in a matrix read from excel file
2 views (last 30 days)
Show older comments
Kundem Durga Sagar
on 17 Jan 2015
Answered: Star Strider
on 17 Jan 2015
I have an excel where there is information of alphabets and numbers. I read the excel in matlab in raw format
Now, I have a column in a big matrix as
[1]
'1A'
[2]
[3]
[4]
[505]
[601]
[7]
[8]
this is how the xlsread command gave it to me. I want to convert all these into strings like ['1' , '1A', '2' and so on..] .
I am struggling to do it. I want no blank spaces in each element. I mean it should not be like [ ' 1', ' 1A', ' 2' and so on]....
Thank you very much in advance.
0 Comments
Accepted Answer
Star Strider
on 17 Jan 2015
Assuming your column is a cell, this works:
C = {[1];
'1A'
[2]
[3]
[4]
[505]
[601]
[7]
[8]};
A = cellfun(@num2str, C, 'Uni',0);
yielding:
A =
'1'
'1A'
'2'
'3'
'4'
'505'
'601'
'7'
'8'
I thought it would have a problem with '1A', but it sailed right through.
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!