xlswrite in case of vectors

ぃ、小莉子 提交于 2019-12-02 08:07:30

You have a couple options. Usually what I do is break it into two xlswrite calls, one for the header and one for the data.

titles = {'time','data'};
time = [1;2;3;4;5];
data = [10;20;30;40;50];

xlswrite('myfile.xlsx', titles, 'Sheet1', 'A1');
xlswrite('myfile.xlsx', [time, data], 'Sheet1', 'A2');

Alternatively, if you have R2013b or newer you can also use the table builtin, which has its own method for writing out data. With the same sample data:

mytable = table(time, data, 'VariableNames', titles);
writetable(mytable, 'myfile.xlsx');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!