Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Edwardo
Posts:
7
Registered:
11/24/12


Re: How to save matrices in a file, effective way
Posted:
Nov 27, 2012 7:31 PM


"Steven_Lord" <slord@mathworks.com> wrote in message <k92qrk$1eu$1@newscl01ah.mathworks.com>... > > > "Edwardo " <edwardo.rivera@upr.edu> wrote in message > news:k8rmsi$70c$1@newscl01ah.mathworks.com... > > Hi, > > > > I a doing a program that multiplies a lot of matrices. All the matrices > > are stores in a cell matrix. where: > > > > cell(index,1) is the matrix in the left cell(index,2)is the matrix of the > > right > > cell(index,3) is the result. > > I want to save a lot of matrices in this way in a file (example): > > > > cell(index,1) cell(index,2) = cell(index,3) > > cell(index,1) cell(index,2) = cell(index,3) > > cell(index,1) cell(index,2) = cell(index,3) > > and so on. > > > > I know that exist the function dlmwrite, but I dont know exactly how to > > use it so that I can have this format. > > If you want more control over the specific format with which your data is > written to the file, look at the FPRINTF function. > >  > Steve Lord > slord@mathworks.com > To contact Technical Support use the Contact Us link on > http://www.mathworks.com
I tried this: fid=fopen("somefile.txt","w") for index=1:size(cell,1) fprintf(fid,"%i %i = %i\n",cell(index,1),cell(index,2),cell(index,3)); end fclose(fid);
but first, I have to convert the matrix that was in the cell, to a matrix (cell2matrix). But the output to the file was bad. it print a matrix, in a line...



