Welcome to CS130R

Course Introduction

Synopsis
Welcome to CS130R: Selected Programming Languages - MATLAB. In this class, we will make introductions, review the course syllabus, and get a brief look at MATLAB.


Activity 1: Meet the class

Please pick up an index card from the front of the class. On the card, fill out the following information:

  1. Name
  2. Year/Class
  3. Major/Undecided
  4. Programming experience (you are not expected to have any prior programming experience)
  5. Reason for taking CS130R (it's ok, you can be honest about requirements)
  6. One specific goal that you hope to accomplish this semester

We will review your goals at the end of the semester to see if we were successful!


Course Syllabus

The course syllabus can be found here


MATLAB Overview

What is it...

MATLAB, or MATrix LABoratory, is a high-level programming language developed and distributed by MathWorks. MATLAB has been adopted across a variety of scientific disciplines because of its extensive library of functions, thorough documentation and ease of use for matrix computations.

What it looks like...

Here is a short block of MATLAB code:

1
2
3
4
%print 5 lines of text
for i = 1:5
    fprintf('the line number is %d.\n',i);
end

We will cover the details of how this code works in a later class, but, for now, here is the output:

the line number is 1.
the line number is 2.
the line number is 3.
the line number is 4.
the line number is 5.

What it can do...

Math. In particular, MATLAB excels at matrix algebra. Here is how we add two matrices:

1
2
3
A = randi(10,3)
B = randi(10,3)
C = A + B
A =

     2     5     5
    10     9    10
    10     2     8

B =

    10     9     8
     7    10     8
     1     7     4

C =

    12    14    13
    17    19    18
    11     9    12

Plotting. Not the nefarious type of plotting, but the type with dots, lines and curves. Here are two examples:

Example 2D Plot Example 3D Plot

Image Processing. One of the most popular MATLAB modules is the Image Processing Toolbox. This toolbox allows you to perform a variety of operations on images. For example, the Wiener Filter is used to deblur images.

Blurred Restored

What can't it do...

Anything fast. MATLAB, along with other high-level languages, is not known for being a speed racer. Even with code optimization, parallel processing and gpu acceleration, MATLAB is often slower than compiled languages.

Play well with others. MATLAB works very well in its own world, but does not integrate well with other languages and services. For example, integrating MATLAB code into a web service is difficult.

What's the punch line...

When you buy a license for MATLAB, you are paying for an extensive library of built-in functions and thorough documentation. These features make MATLAB an ideal high-level language for prototyping and algorithm development. When I want to test an idea, MATLAB is the place I start.


Final Words

In this course, I hope to teach you how to become a practical programmer. In other words, I hope to teach you how to learn. Programming languages are in a constant state of flux, and learning from documentation and online resources is essential to being a proficient coder. So buckle up, and don't forget the semicolon.