Send As SMS

2/15/2006

write an array (or other data) to a file in matlab

to write a file in matlab, you first need to get a file id:

>> fid = fopen('nameofyourfile.txt','w')
(the 'w' means that this file will completely overwrite whatever file shares the same filename)

to write to the file, use the fprint command:
>> fprintf(fid,%d,5);
this puts the number 5 into nameofyourfile.txt.

to prevent the file handling gnomes from attacking you in the night, be sure to close the file when you're finished writing all of your data:
>> fclose(fid);


0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://stinkpot.afraid.org:8080/tricks/ and update your bookmarks.