- the format string need to have 3 conversion operators (or as many as you want on each line).
- the matrix needs to be tranposed.
Converting a matrix of strings to a txt file
1 view (last 30 days)
Show older comments
Commented: Paramonte on 21 Feb 2020
I have a mtarix of strings x_mtarix:
5×3 string array
"A" "B" "C"
"AA" "BB" "CC"
"AAA" "BBB" " "
"AAAA" " " " "
"AAAAA" " " " "
which I would like to save in a text file that woul contain the x_matrix values keping the same appearance:
A B C
AA BB CC
I have used an assortment of variations of:
fid = fopen('output.txt','wt');
But I dont quite get the results I want
Thanks in advance
Stephen23 on 21 Feb 2020
Edited: Stephen23 on 21 Feb 2020
fmt = repmat('%8s ',1,3);
fmt = [fmt(1:end-1),'\n'];
fprintf(fid, fmt, x_matrix.')
More Answers (0)
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!