从Cell数组写入CSV文件的问题

时间:2016-09-21 19:45:49

标签: matlab printf export-to-csv

我来的代码是一个单元格数组,我希望将其打印到csv文件中。

TC(:,1) = T(:,2); %Dates
TC(:,2) = T2(:,7); %PreClosePrice
TC{1,2}{1}={'PreClosePrice'};
TC(:,3) = T2(:,6); %PreSettlementPrice
TC{1,3}{1}={'PreSettlementPrice'};
TC(:,4) = T2(:,8); %PreOpenInterest
TC{1,4}{1}={'PreOpenInterest'};
TC(:,5:6) = T2(:,17:18); %Lower/Upper Limit Price
TC{1,5}{1}={'Lower Limit Price'};
TC{1,6}{1}={'Upper Limit Price'};
TC(:,7) = T2(:,9); %Open Price
TC{1,7}{1}={'Open Price'};
TC(:,8:9) = T2(:,10:11); %Highest/Lowest
TC{1,8}{1}={'Highest Price'};
TC{1,9}{1}={'Lowest Price'};
TC(:,10:33) = T(:,5:28); %Remainder of L2 data

 fid = fopen('TC.csv','wt');
if fid>0

   for k = 1:size(TC{1},1)

       fprintf(fid,'%s\n',[TC{1}{k}]);

   end

end

上面的代码允许我将TC(:,1)写入csv文件,但我似乎无法编写其余文件?

有人可以告诉我如何纠正这个问题,以便我可以将所有数据写入csv文件吗?

由于

巴兹

1 个答案:

答案 0 :(得分:1)