Matlab Environment on Windows

1. Start Matlab on Windows.

 

2. Matlab opens up. 
Command prompt below can be used to give commands to Matlab.

 

3. Type the following two commands.
x is defined to be a vector from 0 to 2*pi with a step of 0.2.
Note that in the first case, the first command ends with ";" .
This means that the user chooses not to see output.

 

4. Typing in the command "plot(x,sin(x),'r')" displays a plot of a
function sin(x) in the interval [0,2*pi] in red color.

 

5. The command "hold on" asks to keep contents of the figure when
the next plot instruction is entered.

 

6. Choose  Desktop->Current Directory  on the menu bar. 
The contents of the current directory will be displayed in
the left pane of Matlab window.

 

While it is possible to use a command prompt to execute commands,
it is recommended to create a Matlab text file ( with .m extension),
type the commands in that file, and execute it.  This way you have
your work saved and easily modified as needed.

1. To create M-file, on the menu bar press File -> New -> M-file.
Editor opens like the one below.

 

2. Type all the commands that we entered in the command window:

 

3. Select Debug-> Save and Run, and save the .m file as myTest.m.
As the program runs, it produces the same output.

 

horizontal rule

Igor Yanovsky