但是,当我打开xlsx文件时,它只显示标题,不显示数字。 我看到xlswrite将显示空单元格,以防我尝试在单元格中导出多个数字。
有什么我可以做的来导出整个向量而不是在它的单元格中写入每个值?
我试图得到的最终结果是这样的:
时间数据 1 10 2 20 3 30 4 40 5 50解决方案
你有几个选项。通常我做的是将它分成两个 xlswrite 调用,一个用于标题,另一个用于数据。
titles = {'time','data'}; time = [1; 2; 3; 4; 5]; data = [10; 20; 30; 40; 50]; xlswrite('myfile.xlsx',标题'Sheet1','A1'); xlswrite('myfile.xlsx',[时间,数据],'Sheet1','A2');或者,如果您有R2013b或更新版本,还可以使用 表 内置,它的自己写出数据的方法。使用相同的样本数据:
mytable = table(time,data,'VariableNames',titles); writetable(mytable,'myfile.xlsx');
I have a .mat file which contains titles={'time','data'} and 2 column vectors: time=[1;2;3;4;5] and data=[10;20;30;40;50].
I created a new cell called table={'time','data';time data} and i used:
xlswrite(filename,table);However, when i open the xlsx file it shows me only the titles and not showing the numbers. I saw that xlswrite will show empty cell in case im trying to export more than 1 number in a cell.
Is there anything i can do to export the whole vector instead of writing each value in it's cell?
The final result that i tried to get is like this:
time data 1 10 2 20 3 30 4 40 5 50解决方案
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');
更多推荐
在向量的情况下为xlswrite
发布评论