MATLAB: Error using ==> fprintf Function is not defined for ‘cell’ inputs.

cell arrayerrorfprintffunction is not defined

Can anyone point out what's wrong with my code? I'm trying to print information to a file with fprintf. I keep getting the error: "Error using ==> fprintf Function is not defined for 'cell' inputs."
fid= fopen('conf1.txt');
fid1=fopen('conf.txt');
fid2=fopen('new_conf.txt','w');
N = 2703;
A = textscan(fid, '%d %s %s %d %f %f %f', N, 'headerlines', 2);
C = textscan(fid1, '%d %s %s %d %f %f %f %f %f %f', N, 'headerlines', 2);
for i = 1:2703
fprintf(fid2,'%5d%5s%5s%5d%8.3f%8.3f%8.3f%8.4f%8.4f%8.4f \r\n', C{1}(i), C{2}(i), C{3}(i), C{4}(i), A{5}(i), A{6}(i),A{7}(i),C{8}(i),C{9}(i),C{10}(i));
end
fclose all ;

Best Answer

textscan returns a cell array with one entry per column. When the column use a string format, the entry is a cell array of strings -- so you have to index the result of textscan as a cell array to get the cell array and you have to index that as a cell array in order to get out a string. Thus, change C{3}(i) to C{3}{i}