Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Are these the values you expect?

The Workspace window shows all the currently defined variables. If you don't see this window, select Desktop Layout > Workspace so  so that a tick mark appears next to the window name.

...

clc; % Clear command window

Another way to do this is to click on the Clear Workspace and Clear Commands buttons.

Create a MATLAB Program

We have essentially used three MATLAB statements to calculate R. These three statements should be shown in the Command History window.

...

If you don't see this window, select Desktop Layout > Command History .

We'll create a MATLAB program to calculate R using the above three statements. Nothing fancy here: the program will just be a text file with the above statements. Such a file is called an M-File. Leta Script File and have the filename extension .m . Let's take a peek at the documentation on M-Files. In the Help window, select

Contents (tab) > MATLAB > Programming > M-File Programming > Working with M-files

Script files. Go in Help > Documentation and search for  Script.

Click on the first hit and glance Glance through this section for future reference. Also search for  Working with files and folders.

Let's now create a Script file and simultaneously bring Bring up the Editor: Select the Command Window by clicking in it. In the MATLAB GUI. From the Home tab, select

File > New > M-File

New Script

First, note that you can dock and undock the editor by clicking on the Show Editor Actions icon .In the Editor, enter the above three statements (you can be lazy like me and copy-and-paste from the Command History; hold down the Ctrl-key to select multiple statements simultaneously). In addition add the clear all and clc commands at the top to start with a clean slate.

Save this file: File > Save

...