# Homework 0

## Professor Howie Choset

### Learning Objectives

• Investigate ways of creating and hosting websites.
• Introduction to basic Matlab and C programming skills you'll need in this course.

### P1. Identify a Robot (30 points)

Find a picture of a robot not from Carnegie Mellon, on the web and display it. Comment on its application in terms of sense, plan, and act.

Deliverable: Create a webpage containing your text answers (and any pictures) in HTML formal. Host it, and submit a link to it in a plain-text file called `p1.txt`. The site must be available for at least one week after the submission deadline to receive credit.

### P2. Matrix-Vector Evaluator (35 points)

Complete a C program to perform 3x1 vector and 3x3 matrix arithmetic. You are required to use this sample code.

The program should take from standard input one line at a time a sequence of expressions, described below:

A line with nothing on it should do nothing. The command `END` should terminate the program.

The following are the commands to be defined:

• Vector and Matrix Assignment

For vectors, a lower case letter followed by an `=` sign, and then followed by three numbers sets the value for the vector. For matrices, an upper case letter, followed by an `=` sign, and then followed by nine numbers sets the value for a matrix. To make things easier, assume there could only be 26 vectors and 26 matrices. Hint: there is a nice relationship between chars and ints in C.

• Printing

A vector or matrix on a line by itself followed by return should print the vector or matrix in their appropriate forms.

c = a + b ------ store the sum of a and b into c.

C = A + B ------ store the sum of A and B into C.

• Multiplication

c = a . b ----- should compute the dot product of a and b and store in it in the first component of c. (Set the other components of c to zero)

c = a * b ----- store the cross product of a and b in c

C = A * B ----- perform matrix multiplication of A and B

v = M * x ----- perform the matrix-vector multiplication.

Take a look at some clarifications, sample input and a sample program here.

Deliverable: Your commented source code named `p2.c`. It must compile and run on the Andrew Unix machines (we will use a build process very similar to the "Tips for compiling in clusters.").

### P3. Using Matlab (35 points)

We'll introduce you to the basics of Matlab here. You may download it for free using your CMU License here. Using these files created by Sarah Tan, complete the following questions.

• Load the robot warrior image you downloaded into Matlab and save it in the variable `ROB`.

• Save each RGB channel of the `ROB` image into `ROB_R`, `ROB_G`, `ROB_B`.

• Create a 10x10 matrix of ones and save it into `ONE`.

• Change the values along the diagonal of `ONE` to 5 and save that variable as `FIVE`.

• Given `TABLE1` and `TABLE2`, remap `TABLE1` and `TABLE2`, replacing the last column with a column of the minimum element of the matrix. For example, if `TABLE1` is ```[1,5; 2,4; 3,2]``` the result should be ```[1, 1; 2, 1; 3, 1]```.

Deliverable: Your commented and compilable matlab code in a file called `p3.m`.

### Submission:

Collect ONLY your deliverables into a tar archive named `[AndrewID]_hw0.tar`, where [AndrewID] is replaced by your Andrew ID, minus the brackets. For example, user with AndrewID `odb` would submit `odb_hw0.tar`. Submit the archive via email to `tdecker@andrew.cmu.edu`. Failure to follow instructions on this homework will result in an automatic zero.

For information on creating a tar archive, please see here. For the most part, while working on Linux, all you'll need to know is that you need to `cd` into the directory containing your deliverables and then type `tar -cvf [AndrewID]_hw0.tar p1.txt p2.c p3.m`.

It is expected that basic navigation abilities on the computing clusters is available. If you are having difficulty or are unable to do so, please notify a TA immediately.