Why does this not make and save a text file

I'm trying to save a string to a text file. My end goal is to be able to create a file called CLIP.XML populated with the text
"<XML>
< /XML>"
I've added a space to force it not to make a link. However, I can't even seem to get anything to write as a text file. My code is shown below.
dataLoc = 'C:\Users\e370305\Desktop\Databases\Test 1';
text = 'XML';
fileLoc = fullfile(dataLoc,'\CLIPPING\CLIPPINGINDEX.txt');
fid = fopen(fileLoc);
fprintf(fid,text);
fclose(fid);
It's not actually generating any file at all. And when the file exists, it doesn't modify it. Is it the way I'm specifying the location or something else?

 Accepted Answer

fid = fopen(fileLoc, 'w');
% ^^^
Otherwise the file is opened for reading only, not for writing.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Release

R2017b

Asked:

on 6 Aug 2018

Answered:

Jan
on 6 Aug 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!