fprintf command reading my input matrix by column and displays incorrectly.
2 views (last 30 days)
Essentially I am trying to take input data for a structure and print it to a text file. When using fprintf Matlab reads the data by the column and inputs it incorrectly to what I need. I know it's supposed to do that, but my question is how would I code around it to get the matrix to show up correctly on my data sheet. Here is the relevant code along with the text file output.
COORD = [0 0;5 0;0 5]*1000;
fileID = fopen('DataSheet.txt','w');
I know the fix is probably very siimple but for the life of me I can't find what I'm doing wrong online. Any help would be appreciated.
Stephen23 on 26 Nov 2022
Edited: Stephen23 on 26 Nov 2022
% ^^ transpose
"I can't find what I'm doing wrong online"
The FPRINTF documentation states on the first line "...applies the formatSpec to all elements of arrays A1,...An in column order ...", if you want it to apply the format in row order then just transpose the input matrix.