Session 6:
MATLAB Introduction
Supplemental Instruction
IowaStateUniversity / Leader: / Becca
Course: / ChE 160
Instructor: / Heinen & Haman
Date: / 09/14/2016

Resources

  • YouTube is a great resource for helping you find your way around MATLAB
  • MATLAB Help (question mark in upper right hand corner or typing “help” in command window”. You can search for whatever you want to find help files on your topic!

Overview

What is MATLAB?

-Fancy, powerful calculator

How do you program?

-It is talking to a computer in a certain language, just like there are different world languages to communicate. Set things up in a logical manner with commands that are recognized by the software program.

Should you freak out about this??

-NO WAY! It is great. It may take some time, but programming will pay off in the future, especially with the complex problems of the world today.

MATLAB Basics

Tip: Fill out the reference notecard and KEEP IT WITH YOU! It will help you get faster when programming.

Review

So far, how would you explain MATLAB to someone unfamiliar with the program?

Explain what happens when you type:

clc

clear

%

;

\n

How do you assign a number to a variable?

What is colon notation used for and what are the necessary components of the code?

What is the function linspace used for and what are the necessary components of the code?

How do you pick a point in a matrix or vector?

How do you transpose (flip) a vector or matrix?

Practice

Write the code by hand and check by MATLAB

Enter the following vector and assign it to the variable Yay_Vector1.

Transpose Yay_Vector1and save as Sideways_Vector1. Multiply the new vector by 3 and assign it to a variable name of your choice.

Enter the following vector and assign it to the variable Amazing_Vector2.

Transpose Amazing_Vector2 and write a comment saying whether it is now a row or column vector. Save this new vector as Flipped_Vector2.

Enter following matrix and assign it to the variable Cool_Matrix1.

Select all values in column 2 and save it as Middle_Column.

Enter the following matrix and assign it to the variable I_Love_MATLAB.

Select all values in row 1 and save it as Winning_Row.

Clear the command window and then use colon notation to create a vector starting from 1 to 27 with a step size of 0.4.

Clear the workspace and then use colon notation to create a vector starting from 65 to 6500 with a step size of 25.

Use linspace function to create a vector starting from 12 to 24 with a step size of 4.

Use linspace function to create a vector starting from 12 to 24 with 4 values.