MATLAB: Could you like to help to solve a problem with cell arrays in a text file? How could I print these kind of data with the function fprintf

#fprintf #cell

For example, I have a matrix H:
H = [1 2 3; 4 5 6; 7 8 9];
I want to do a file (attached) like:
AB CDEFG 1 2 3
AB CDEFG 4 5 6
AB CDEFG 7 8 9
I wrote this:
fileID = fopen('output.txt','w');
fprintf(fileID,'%2s %5s %1.0f %1.0f %1.0f\r\n','AB','CDEFG',H);
fclose(fileID);
But it doens't work. How can I do this?
Thank you in advance!

Best Answer

fprintf(fileID,'AB CDEFG %1.0f %1.0f %1.0f\r\n', H');