How to print an array to a text file in MATLAB
I have an array of vectors:
array = [0 0 0 0 0 0 1
0 1 1 1 0 1 0
1 1 1 1 0 0 0
........开发者_如何学编程.....
.............]
and I want to print it into a file as it is:
0000001
0111010
1111000
....
....
etc.
I have this but it does not seem to work:
myoutput = fopen('c:\\aitest_file.txt', 'wt');
fprintf(myoutput, '%f\n', VAA_final);
fclose(myoutput);
dlmwrite('c:\aitest_file.txt', VAA_final, 'delimiter', '');
You need to transpose your output matrix and use the appropriate number of integer identifiers:
>> VAA_final = [0 0 0 0 0 0 1; 0 1 1 1 0 1 0; 1 1 1 1 0 0 0] VAA_final = 0 0 0 0 0 0 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 >> myoutput = fopen('aitest_file.txt', 'wt'); >> fprintf(myoutput, '%u%u%u%u%u%u%u\n', VAA_final'); >> fclose(myoutput);
精彩评论