Excel spreadsheet - using xlswrite only writes first value to spreadsheet

I am writing a vector from the workspace to an Excel spreadsheet, and specifying the range. But I only see the first number in the vector being written over and over again. 
As an example : 
>> x = 1:10;
>> xlswrite('temp.xlsx', x, 'A1:A10');
Now, on opening the "temp.xlsx" file, I can see that only the number "1" is written 10 times from A1 to A10. Why is this? 

 採用された回答

MathWorks Support Team
MathWorks Support Team 2016 年 12 月 28 日
When specifying the "range" in the "xlswrite" function, ensure that if a "row" range is specified, then the variable is a row vector. Similarly, if a column range is specified, ensure that the input is a column vector. 
In this case, a row vector is the input, and the range specified is a column. 
To fix this, simply use the transpose operator on the variable x as follows : 
>> x = 1:10;
>> xlswrite('temp.xlsx', x', 'A1:A10');

その他の回答 (0 件)

製品

リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by