Putting character arrays and numeric variable types together in a matrix is not appropriate.
Try this instead:
countries = ['AUS'
'AUT'
'BLR'
'CAN'
'CHN'
'CRO'
'CZE'];
results = [ 2 1 0 3
4 6 6 16
1 1 1 3
14 7 5 26
5 2 4 11
0 2 1 3
2 0 4 6];
fprintf ('Countries Gold Silver Bronze Total\n')
for n = 0:length(results)-1
fprintf (' %s %2.0f %2.0f %2.0f %2.0f\n',countries(n+1,:), results(n+1,1), results(n+1,2), results(n+1,3), results(n+1,4))
if n == length(results)
break
end
end
You might be able to do that with string arrays (I didn’t test that), although certainly not with character arrays.
