필터 지우기
필터 지우기

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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by