how to write data to xls sheet?

조회 수: 164(최근 30일)
Arun Badigannavar
Arun Badigannavar 2013년 1월 24일
댓글: nehad mohamed 2021년 1월 17일
value_F = 0.1,0.2,0.3,0.4,0.5,0.6
filename = 'C:\Documents and Settings\admin\Desktop\test.xlsx';
value_F
Data= {'value_F';value_F};
sheet = 1;
xlRange = 'B';
xlswrite(filename,Data,sheet,xlRange)
where value_F is calculated from simulink model and asiigned to workspace,,,am able write oly value_F,,,am unable to write all the values of value_F
  댓글 수: 1
nehad mohamed
nehad mohamed 2021년 1월 17일
how to write all value for F every value in cell in sheet

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2013년 1월 24일
Try using 'B1' for the range and not just 'B' - it should correspond to what ranges look like in Excel. Next, all cells in your cell array go into a cell in Excel, so you can't have a whole array in one cell. I've looked over my Excel writing code and I put all each element in a numerical array into their own cell. So have a for loop where you iterate over all numbers in your numerical array and put them into their own cell, something like this (untested):
[rows columns] = size(value_F);
myCellArray = cell(rows+1, columns);
myCellArray{1,1} = 'value_f'; % First row has only this
% Now assign rows 2 and lower of our cell array.
for col = 1 : columns
for row = 1
myCellArray{row+1, column} = myNumericalArray(row, column);
end
end
xlswrite(filename, myCellArray, sheet, xlRange)

추가 답변(3개)

Jing
Jing 2013년 1월 24일
편집: Jing 2013년 1월 24일
If there're both CHAR data and DOUBLE data, I prefer to use XLSWRITE twice to make it work without extra effort. Here I assume value_F is a double matrix.
xlswrite(filename,data(1),1,'A1');
xlswrite(filename,data{2},1,'A2');
  댓글 수: 3
Arun Badigannavar
Arun Badigannavar 2013년 1월 25일
thanks am able to write it,,,

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2013년 1월 24일
value_F = [0.1,0.2,0.3,0.4,0.5,0.6];
  댓글 수: 1
Arun Badigannavar
Arun Badigannavar 2013년 1월 24일
for making simple,,i have shown some data for value_F here,,,but actually value_F is coming from workspace,,around hundred values i will get it,,how to write those

댓글을 달려면 로그인하십시오.


Sachin Ganjare
Sachin Ganjare 2013년 1월 24일
Check the type of workspace output variable using "whos ,var_name". It could be a problem with type of data being written in excel.
  댓글 수: 1
Arun Badigannavar
Arun Badigannavar 2013년 1월 24일
value_F 2x1 16 double

댓글을 달려면 로그인하십시오.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by