Matlab CSV excel文件写入
我在CSV excel文件中有以下格式的数据:Matlab CSV excel文件写入,matlab,Matlab,我在CSV excel文件中有以下格式的数据: Column1 Column2 Column3 Column4 23 45 67 56 34 456 54 58 56 32 53 56 我想再添加一列,即第5列,仅包含1或0个值: Column1 Column2 Column3 Column4
Column1 Column2 Column3 Column4
23 45 67 56
34 456 54 58
56 32 53 56
我想再添加一列,即第5列,仅包含1或0个值:
Column1 Column2 Column3 Column4 Column5
23 45 67 56 0
34 456 54 58 0
56 32 53 56 1
可以写吗?如何完成这项任务
h = actxserver('Excel.Application'); % Open Activex Server
e = h.Workbooks.Open('test.csv'); % Open file
% Give full path if your path is not set like this: 'D:\Assignment\test.csv'
e.ActiveSheet.Range('E1:E3').Value = round(rand(3,1)); %Writing required data
e.Save % Saving the changes
e.Close(false) % Closing the file
h.Quit % Quitting the Activex server
比较:
是的,这是可能的。你试过什么?M=randn(4,4);dlmwrite('test.csv',M,'delimiter',',');N=randn(4,4);dlmwrite('test.csv',N,'delimiter',',',','-append');我用过这段代码,但它不是在每行的末尾打印,也不知道只打印0和1。你能帮我查一下密码吗@苏伊弗