Excel help
2 次查看(过去 30 天)
显示 更早的评论
my question is i have a data x = [2 6 7 13 27 100] and i want to store it as one data into excel. i used num2str(x) so all the data will be in one box of excel table. however, when i want to read it back i have to convert cell2mat the data which effect that it only read data as separate number. for example 27 will be 2 and 7 and 100 will be 1, 0 and 0.
what i try to do is store the data x into one cell on excel and can read back as number.
0 个评论
采纳的回答
Friedrich
2012-5-23
Hi,
at least this works fine for me:
x = [2 6 7 13 27 100]
xlswrite('test.xlsx',{num2str(x)})
[~,data] = xlsread('test.xlsx')
str2num(data{1})
2 个评论
Friedrich
2012-5-23
data is a cell where you like to get the string which it contains. So data{1} gives you the value of the first element in that cell data, which is the string from EXCEL. When you would call str2num(data) you would see an error message like "Requires string or character array input".
So, this wont work because its a cell containing a string: str2num({'1'}). But you actually want str2num('1'). Thats why you have to index in it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!