Save 512x512 matrix to text file

10 views (last 30 days)
Vinh Nguyen
Vinh Nguyen on 27 Apr 2013
Dear all,
I try to save an 512x512 matrix of lena image into text file, which will be used for fpga processing.
I have use the recommended code:
A = round(rand(6,7)*9) % Write this to file.
fid = fopen('Mymatrix.txt','wt');
for ii = 1:size(A,1)
However, the output file miss many coefficients.
Is there any method to create an complete text file with tab between coefficients ?
Thank you

Answers (1)

Ahmed A. Selman
Ahmed A. Selman on 27 Apr 2013
This code works perfectly. To check it add the following at the very end of the above code:
fid = fopen('Mymatrix.txt','r');
[A1,n]=fscanf(fid,'%g %g',[7 inf]);
fprintf(1,'Data being fed from the file is :\n')
and compare A1 with (the original data) A.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!