Reputation: 2150
I have come code that is held in a cell array which I wish to print to a csv file.
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
The code above allows me to write the TC(:,1) to the csv file but I can't seem to write the rest?
Can someone show me how to correct this so that I can write all the data to the csv file?
Thanks
Baz
Upvotes: 0
Views: 25
Reputation: 3440
Use an already working code. cell2csv https://www.mathworks.com/matlabcentral/fileexchange/4400-cell-array-to-csv-file--cell2csv-m-
Upvotes: 1