MATLAB: How to print .txt from the matrix containing numbers and characters

for loopfprintfstringtext file

I want to print the following data into a .txt file.
1 0 R 1km
2 0 R 1km
3 0 R 1km
……
…..
99 0 R 1km
100 0 R 1km
How can I use fprintf to save this data?

Best Answer

Something like this
tt = table((1:100).', zeros(100,1), repmat('R', 100, 1), repmat('1km', 100, 1));
writetable(tt, 'data.txt', 'WriteVariableNames', false, 'Delimiter', '\t')