Lesson 1

Getting Started

1

Note that you will need KTH log in credentials to download the latest version of MATLAB

Step 1 : Installation

  • Go to: http://www.kth.se/student/support/itsc/progdist/

  • Click on Software for Windows, Mac OS X or Linux

  • Select the latest version of MATLAB (e.g. MATLAB 2013A)

  • Follow the online installation instructions


Installation Guide on KTH website (see link above)


Step 2: Setting up your directory

  • Create a folder on your desktop that will serve as your directory

  • Select the path to that folder in the Current Folder tab (See picture below)


Set the "Current Folder" to the directory of your choice.


Selecting a directory allows you to run the files and scripts saved in that particular folder.

Step 3: Create your first .m file

  • Click on New Script to open the editor and create your first .m file!


The "New Script" button is the shiny white paper sheet on the top left


  • Copy & paste the following code to your new script

  • Save your script in your directory

  • Click the green play button to run the code


Click the green play button to run the code, you should see the message appear in your Command Window


Note: when saving an .m file do not use spacing, e.g.


my file.m (This will not run!)


myfile.m (This will run!)

Step 4 : Explore the program

Everybody should spend some time exploring the tabs on the top of the page and get acquainted with the disposition of the program. The three most important elements you need to keep track of is the Command Window, the Editor and the Workspace.


The Command Window is your console and will display whatever code you choose to run in the editor. You can directly type in programming commands in the command window and get instant feedback, the downside is that it won't be saved. Try typing in disp('Hello Ludu') in your command window to see what happens!


The Editor is your paper sheet where you do your coding. You can for example write multiple scripts and then have a single one call the others to get executed. This is the place where you define how your script is going to run and then save those instructions for later use.


The Workspace is where all the variables or parameters you define are saved after you run your code. There are several variable types that can be defined and we will talk more about that later. You can use your workspace variables to plot figures, do numerical calculations and many more.


Here is a quick video from Mathworks explaining how to get started with MATLAB

Note that your MATLAB start page might differ depending on what version you are using.

Comments

icon

Be the first to comment!