How DOS Prompt & MATLAB Command Window Are The Same?
Yes there are many Similarities between, DOS command prompt ( that you can still access by typing "cmd", in the run window of Windows OS ) & MATLAB's command window working. Thats sometimes give a feeling, that a lot of things in MATLAB, inspired from this good old operating system. Lets see how..!
Clear Window Command --> clc
This command when given, in matlab, it clears the current command window. Its similar to "cls" [clear screen] command of DOS Prompt.
Print Work Directory --> pwd
This command prints the current working directory in matlab. It takes no input as the argument. But echoes a string in output, that represent the current working directory. This command is similar to "cd", command of DOS Prompt, which when typed without any preceeding word will echo the current directory.
Directroy List Command --> dir
This command in MATLAB has 2 forms, functional form & command form.
dir('name_of_directory') %Functional form
dir name_of_directory %Command Form
In either of the above mode MATLAB will list all the names of files & directory under the directory named 'name_of_directory'. [ but it should be an existing one, other wise it will echo an error ]
dir command in MATLAB, just like the DOS Prompt counterpart supports the wildcards, for example the command, dir E:\xyz\*.m, will list all the files in the directory in E:\\xyz\\ having the file extension of .m.
But when we use dir as function it returns not a string, but a structure, e.g., dir('E:\xyz\*.m'), now it will return a nX1 structure, where n is the number of .m files in that directory. So we can process the above collected data is different way.
The above command of MATLAB Command window is very similar to DOS prompt, command DIR. Through which we can get the same result [Except the result when we use the functional form in MATLAB].
Make Directory Command --> mkdir
Just like dir command, this command in MATLAB has 2 forms, functional form & command form.
mkdir('name_of_directory') %Functional form
mkdir name_of_directory %Command Form
Suppose the name of directory we have choosen is "d1", so we have to type as "mkdir d1".
Yes just like DOS, we can also make multiple directory in a single command, just my typing "mkdir d1, d2". When using in it in functional form we should type as mkdir('d1','d2'). The functional form returns the value of 1 if the directory creation is successfully done, 2 if the required directory is already in existance & 0 is unsuccessful in making it, so this thing can be put into a proper use, when it required. The directory name can be relative or a complete address may be provided to create it.
Change Work Directory COmmand -->cd
It hace 2 forms, functional & command form.
cd dir_path or cd('dir_path')
Above is similar to CD command of DOS Prompt.
"cd ..", will be command, to change the current working directory to a higher one. Just like that of "CD..", command of DIS prompt.
NOTE :- "cd" without any input params, is equivalent to "pwd" command.
Copy File Command -->copyfile
Simply type, copyfile('source','destination'), to use it.
Here Source can be a full path addressing the, directory path, file name & file extension, same thing for the 'destination'. Yes the source & destination can be different, in path.
This command is similar to COPY command of DOS Prompt.
Delete File Command --> delete
Type as , delete filename or delete('filename'), the 'filename' can be a file in the current working directory, or a full path specified to the file to be deleted. We can also use wildcards in this command as, "delete *.m", this command will delete all the ".m", files from the current working directory.
Print current Date command --> date
Type "date" in the MATLAB command window and it will return today's date. Just like the "DATE" command in the DOS Prompt.
Closing MatLAB command -->quit
Just type "quit" in MATLAB's Command prompt, and the MATLAB will close, it is similat to "EXIT" command of DOS Prompt.
NOTE:- DOS is not case sensitive, but MATLAB is!
Clear Window Command --> clc
This command when given, in matlab, it clears the current command window. Its similar to "cls" [clear screen] command of DOS Prompt.
Print Work Directory --> pwd
This command prints the current working directory in matlab. It takes no input as the argument. But echoes a string in output, that represent the current working directory. This command is similar to "cd", command of DOS Prompt, which when typed without any preceeding word will echo the current directory.
Directroy List Command --> dir
This command in MATLAB has 2 forms, functional form & command form.
dir('name_of_directory') %Functional form
dir name_of_directory %Command Form
In either of the above mode MATLAB will list all the names of files & directory under the directory named 'name_of_directory'. [ but it should be an existing one, other wise it will echo an error ]
dir command in MATLAB, just like the DOS Prompt counterpart supports the wildcards, for example the command, dir E:\xyz\*.m, will list all the files in the directory in E:\\xyz\\ having the file extension of .m.
But when we use dir as function it returns not a string, but a structure, e.g., dir('E:\xyz\*.m'), now it will return a nX1 structure, where n is the number of .m files in that directory. So we can process the above collected data is different way.
The above command of MATLAB Command window is very similar to DOS prompt, command DIR. Through which we can get the same result [Except the result when we use the functional form in MATLAB].
Make Directory Command --> mkdir
Just like dir command, this command in MATLAB has 2 forms, functional form & command form.
mkdir('name_of_directory') %Functional form
mkdir name_of_directory %Command Form
Suppose the name of directory we have choosen is "d1", so we have to type as "mkdir d1".
Yes just like DOS, we can also make multiple directory in a single command, just my typing "mkdir d1, d2". When using in it in functional form we should type as mkdir('d1','d2'). The functional form returns the value of 1 if the directory creation is successfully done, 2 if the required directory is already in existance & 0 is unsuccessful in making it, so this thing can be put into a proper use, when it required. The directory name can be relative or a complete address may be provided to create it.
Change Work Directory COmmand -->cd
It hace 2 forms, functional & command form.
cd dir_path or cd('dir_path')
Above is similar to CD command of DOS Prompt.
"cd ..", will be command, to change the current working directory to a higher one. Just like that of "CD..", command of DIS prompt.
NOTE :- "cd" without any input params, is equivalent to "pwd" command.
Copy File Command -->copyfile
Simply type, copyfile('source','destination'), to use it.
Here Source can be a full path addressing the, directory path, file name & file extension, same thing for the 'destination'. Yes the source & destination can be different, in path.
This command is similar to COPY command of DOS Prompt.
Delete File Command --> delete
Type as , delete filename or delete('filename'), the 'filename' can be a file in the current working directory, or a full path specified to the file to be deleted. We can also use wildcards in this command as, "delete *.m", this command will delete all the ".m", files from the current working directory.
Print current Date command --> date
Type "date" in the MATLAB command window and it will return today's date. Just like the "DATE" command in the DOS Prompt.
Closing MatLAB command -->quit
Just type "quit" in MATLAB's Command prompt, and the MATLAB will close, it is similat to "EXIT" command of DOS Prompt.
NOTE:- DOS is not case sensitive, but MATLAB is!