MATLAB: I have some results from the codes. Their class are different to each other. I write these values into microsoft word. I can assign global and char data into word with fprintf but when it comes to cell data I can’t find anyway to write it.

cell array

[fileName, filePath] = uiputfile('*.doc', 'Create a file:')
if ~ischar(fileName)
return;
end
fileID = fopen(fullfile(filePath, fileName), 'w');
dx=100 %global


formatSpec = 'dx(m) '; %char

formatSpec2=0.005; %global
formatSpec2=num2str(formatSpec2) %char
formatSpec2_2=100; %global
fprintf(fileID,'%3s %20s %30f\n',formatSpec,formatSpec2,formatSpec2_2)
cellArray=
'p.4004'
'p.4005'
'p.4007'
'p.4009'
cellArray 4x1 1240 cell global
%how can I write this cellArray into microsoft word as they appear?
fclose(fileID)

Best Answer

cellArray={'p.4004'
'p.4005'
'p.4007'
'p.4009'}
fileID = fopen('fic.txt', 'w');
fprintf(fileID,'%s\n',cellArray{:})
fclose(fileID)