MATLAB: Using fprintf to open a .txt file of text (NOT data)

fprintftext filetxt

Hey guys, I'm new here. I'm having some issues with using the fprintf command. I want to use it to print actual words (NOT data, like a matrix) to a .txt file on my desktop. I've been all over the internet trying to figure out how to do this, but I can't seem to find anything regarding the fprintf command and opening things that aren't data sets.
Thanks in advance, Luke

Best Answer

fid=fopen('test.txt','w');
str='Actual textual thing, Once upon a time there was a princess trapped in the tower.';
fprintf(fid,'%s\n',str);
str='Same old story, at the end some guy freed the princes.';
fprintf(fid,'%s\n',str);
fclose(fid);