MATLAB: What is the command for making a brand new script, by an already existing script

command

The command mkdir('folder name') creates a folder at current location. I search for the command that creates a script instead. (I wonder too where to read about it)

Best Answer

You need three commands, at least. First call fopen(), then frpintf() as many times as you need, then fclose():
fid = fopen('myScript.m', 'wt');
fprintf(fid, 'clc;\n');
fprintf(fid, 'workspace;\n');
fprintf(fid, 'close all;\n');
% etc. for however many commands you want to put into your m-file.
fclose(fid);