From: David Young on 22 May 2010 07:27 "roya olyazadeh" <roya2543(a)gmail.com> wrote in message <ht6lu6$jsm$1(a)fred.mathworks.com>... > "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <ht6cmd$98r$1(a)fred.mathworks.com>... > > Have a look at the documentation for fprintf. It's pretty straightforward, but if you have problems using it you can always come back here. > > > With fprintf how can I export my data to text file ???? I am looking for a function like textread but vice versa for writing to a text file . Well, from the documentation for fprintf: "fprintf(fileID, format, A, ...) applies the format to all elements of array A and any additional array arguments in column order, and writes the data to a text file." So it is just like going in the opposite direction to textread and seems to correspond to exactly what you asked for. Can you explain a little more what you need help with? Is it that you have to call fopen to get the fileID?
From: roya olyazadeh on 23 May 2010 10:43 "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <ht6cmd$98r$1(a)fred.mathworks.com>... > Have a look at the documentation for fprintf. It's pretty straightforward, but if you have problems using it you can always come back here. Hey .. one problem occurred when I use like this : fprintf(fid,'SIGNIFICANCE LEVEL = .050\n'); fprintf(fid,'DF1 = %d DF2 = %d \n',df1,df2); '\n' did not run. and all my results in text file are appeared in one line. do you know what is the problem ?
From: dpb on 23 May 2010 11:03 roya olyazadeh wrote: > "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message > <ht6cmd$98r$1(a)fred.mathworks.com>... >> Have a look at the documentation for fprintf. It's pretty >> straightforward, but if you have problems using it you can always come >> back here. > > Hey .. one problem occurred when I use like this : > fprintf(fid,'SIGNIFICANCE LEVEL = .050\n'); > fprintf(fid,'DF1 = %d DF2 = %d \n',df1,df2); > '\n' did not run. and all my results in text file are appeared in one > line. do you know what is the problem ? Works here (although you need an additional "\n" to terminate the last line). Which OS? Where's your fopen() call? If Windows and didn't, make sure use the 't' option to specify text file... fid=fopen('filename', 'wt'); % Need the "t" on Winders... Just did confirmation test; on Windows w/o the 't' fprintf() did, indeed not include the newline characters (CR/LF), simply the LF (x0A) which isn't recognized by most Windows text tools as equivalent to the \n. --
From: Walter Roberson on 23 May 2010 11:15 roya olyazadeh wrote: > "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message > <ht6cmd$98r$1(a)fred.mathworks.com>... >> Have a look at the documentation for fprintf. It's pretty >> straightforward, but if you have problems using it you can always come >> back here. > Hey .. one problem occurred when I use like this : > fprintf(fid,'SIGNIFICANCE LEVEL = .050\n'); > fprintf(fid,'DF1 = %d DF2 = %d \n',df1,df2); > '\n' did not run. and all my results in text file are appeared in one > line. do you know what is the problem ? Are you possibly using Windows, and did you possibly forget to include the 't' parameter when you opened the text file? fopen(filename, 'wt'); %t is needed for text files
First
|
Prev
|
Pages: 1 2 Prev: Two way flow through pipe Next: how to solve a complex equation with symbolic coefficients? |