Code covered by the BSD License  

Highlights from
Write text file

Be the first to rate this file! 1 Download (last 30 days) File Size: 1.41 KB File ID: #25933

Write text file

by SamGhim

 

23 Nov 2009

write_txt_file - creates a .txt file with desired information as specified by "info_str)

| Watch this File

File Information
Description

write_txt_file - creates a .txt file with desired information as
specified by "info_str)

 function calls :
       WRITE_TXT_FILE(LOGPATH,FILENAME,INFO_STR)

LOGPATH = pathname (as a string) to the folder where the file is to be saved, ex: 'C:\Desktop'
FILENAME = name of the file (as a string), ex: 'test.txt'
INFO_STR = information that you want to be written in the file, ex: a variable or a string such as 'testing file'

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
24 Nov 2009 Jan Simon

file = strcat(logpath,'\',filename)
can be improved:
file = fullfile(logpath, filename);
This considers a trailing file separator in the path and different separator for Unix and Windos.

if exist(file), fid = fopen(file,'at');
else, fid = fopen(file,'wt'); end
EXIST(Key) without specifying the type is very slow, because it tests for files, folders, variables, classes, ... Better use "exist(file, 'file')" -- but even better: omit the EXIST and use "fopen(file, 'at+')".

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
text file SamGhim 24 Nov 2009 09:50:08

Contact us at files@mathworks.com