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?

 采纳的回答

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

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Environment and Settings 的更多信息

产品

版本

R2017b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by