Info
此问题已关闭。 请重新打开它进行编辑或回答。
Displaying array in a cell
2 次查看(过去 30 天)
显示 更早的评论
I am trying to copy an already existing column vector into a cell array and have it display as a column when I import in excel using xlswrite. Here is my code.
Table={'Gray Shade','Digital Units','LE 100% Night','LE 50% Night'; grayShade digUnits stepsN100L stepsN50L);
xlswrite('Gamma Stability.xlsx', Table, 'Gray Shade Table', 'B2');
What I am trying to get is for the first four entries in Table to be the column headers and for the last four to be the data after the columns. The variables grayShade, digUnits, stepsN100L, and stepsN50L are all 17 rows by 1 column in size. When I execute this command, it writes Table, but it comes out as a 2x4 cell array with the column headers in the first row, and every cell in the second row saying '17x1 double'. Not sure how to make it write in the actual data. I would like my cell array to be an 18x4 when I am done.
0 个评论
回答(1 个)
Jan
2013-4-29
Table = cat(1, ...
{'Gray Shade','Digital Units','LE 100% Night','LE 50% Night'}, ...
mat2cell([grayShade digUnits stepsN100L stepsN50L]));
2 个评论
Jan
2013-4-30
@Alex: And then you started to analyse what's going on, correctly? Or are you waiting for me?
I cannot know the dimensions of grayShade etc., therefore I cannot guess, how this command have to look like exactly. But you have all information about this, to I encourage you to try to solve it. Perhaps you want:
mat2cell([grayShade(:), digUnits(:), stepsN100L(:), stepsN50L(:)])
You cannot simply omit the "...", which are the line continuation makr in Matlab.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!