See if this is more along the lines of what you need
A = [1 2 3;4 5 6]
b = {'a' 'b' 'c' 'd'}
Ac = split(sprintf('%G\n',A')) % convert numeric to cellchar
Ac = reshape(Ac(1:end-1),size(A)) % reshape
Ac = [Ac {' '; ' '}]; % append spaces
C = [Ac(1,:); b; Ac(2,:); b].' % concatenate and transpose
fileID=fopen('AB.inp','w');
fprintf(fileID,'\n%s, %s, %s, %s',C{:});
fclose(fileID);