When using fopen, what's the difference when we include/exclude 'w' in the second half of the parenthesis?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Suppose we want to open a file called exp.txt using fopen. What is the difference between these two code snippets:
fid = fopen('exp.txt', 'w');
fid = fopen('exp.txt');
0 Kommentare
Antworten (1)
Harry MacDowel
am 23 Nov. 2013
The 'w' simply means write.
So if the file 'exp.txt' does not exist, that command will create exactly the file, and allows you to write to it.
If the file is already there, then it will overwrite the original content.
Without the 'w', Matlab just read the file, that's all.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!