フィルターのクリア

Excel help

2 ビュー (過去 30 日間)
reez all
reez all 2012 年 5 月 23 日
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.

採用された回答

Friedrich
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 件のコメント
reez all
reez all 2012 年 5 月 23 日
Its work. thank you very much. Just a want to know, why we have to put {1} at str2num(data{1})?
Friedrich
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 ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by