SUNY Geneseo Department of Computer Science


Lesson 1—The Interactive Matlab Environment

CSci 120, Spring 2014

Prof. Doug Baldwin

Complete by Monday January 27 (Monday recitation)
or Wednesday January 29 (Wednesday recitation)

Purpose

This lesson introduces you to the computing environment you work in when using Matlab: the windows, menus, commands, etc. through which you control Matlab. You will need to be comfortable using this environment in order to write and run programs throughout the rest of this course.

Background

More than being the name of a programming language, “Matlab” is also the name of a computer application through which you use the language. As an application, Matlab offers you a set of windows and menus through which you can either use Matlab interactively, like a glorified calculator that responds to commands typed to it, or create and run Matlab programs. This lesson gives you some practice using this Matlab environment, and some exposure to terminology associated with it.

Preparatory material for this lesson is as follows. Please read or watch all of these before coming to class:

Exercise

Answer the following groups of questions, using Matlab to find or test your answers wherever possible.

Question 1

What does Matlab’s diary command do? What about the clc command? How do you issue commands such as these to Matlab?

Question 2

In your own words, what is Matlab’s “path”? Why does the path matter to you as a Matlab user? How can you change the path?

Question 3

How would you find out if Matlab has a command that does nothing? (Such a command would be strange, but not completely useless—for example a program that controls an automatic door probably has to wait for a sensor to indicate a person near the door, and while waiting it does nothing. In the early days of computing such a command was called a “no-op,” today it might be described as a “null command” or “null statement.”) Does Matlab have such a command?

Question 3

See if you can get Matlab to act as a simple calculator, for example see if you can get it to tell you what 1 + 2, or some similarly trivial expression, is. (This question is really setting the stage for the next lesson; none of the readings or lectures for this one explicitly talk about doing arithmetic in Matlab. But you can do at least some arithmetic just by typing the “natural” thing in the right place….)

Follow-Up

In your study group’s first face-to-face meeting with me following your “Complete By” date above, I will look over your answers to the questions, ask you any further questions I have, and answer any questions from you. I may also ask you to demonstrate some of your answers in Matlab. Please bring short written answers to each question to the meeting. This will speed the meeting along, but because we will also be talking face-to-face, the written answers don’t have to be long or elaborate.

If you aren’t already signed up for a study group meeting during the week following this recitation, please sign up. Make the meeting 15 minutes long, and try to make it at a time all members of your study group can attend. If no such time exists, make it at a time the greatest number of members can attend.