Directories…. The address of your programs…


In the previous article on Matlab Desktop, you may have got idea how this software works. You need to save the files for the future use. Now where to save these files? It should be saving in the manner where it can be access by the MATLAB. You can create your own directory/folder anywhere, save your files, and direct MATLAB to find those files. It is convenient to save files in the same folder of the MATLAB where its application files are installed because it gives all the user written files an automatically accessible by MATLAB.
But I always prefer to save my written files in the folder which contains my data about the relevant project as MATLAB also provides you an alternative to above method i.e. change directory command when you press ‘run button’ , which looks like the following window.

             

·         Change folder Option: - This option changes the current directory of the Matlab and will only allow you to access files of that folder/directory.

·         Add to Path: - This option unable you to add the path of your program to the existing list of the path/directories in the Matlab. Due to this option , you will be able to access the current directory as well as the folder in which your current program is.

·         Cancel: - To cancel your operation.

·         Help: - Help provides the necessary information of how you can use this dialog box in case you find it difficult or confusing.

You can also change the path command or change the working directory of MATLAB to the desired directory with the cd command.

Let us see how to do it in PC’s
Step-1
Create a folder inside the MATLAB folder and save your files there.

Step-2
Create a file in notepad or any word doc. And save this file with the extension of “.m”, let us take “fun.m” and now launch MATLAB by double-clicking on the ‘fun.m’ file in your folder.

Step-3
This way Matlab automatically accesses all files in your folder. You can open, write and save M-files by selecting appropriate commands from the File menu in MATLAB.

Hope to see you in next tutorial...!!!

Written By, Dheeraj Mor

Student @ VIT University