×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

### Create a StudySoup account

#### Be part of our community, it's free to join!

or

##### By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

## ENGR 121: Week 2 Lecture Notes

by: spencer.kociba

70

0

3

# ENGR 121: Week 2 Lecture Notes ENGR 121-B

Marketplace > Drexel University > Engineering and Tech > ENGR 121-B > ENGR 121 Week 2 Lecture Notes
spencer.kociba
Drexel

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

### Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

Summary of Lecture: how to classify, categorize, modify and conduct operations using matrices and vectors in MATLAB (which stands for Matrix Laboratory)
COURSE
Computation Lab I
PROF.
TYPE
Class Notes
PAGES
3
WORDS
CONCEPTS
Engineering, Matlab, coding, programming
KARMA
25 ?

## Popular in Engineering and Tech

This 3 page Class Notes was uploaded by spencer.kociba on Sunday October 2, 2016. The Class Notes belongs to ENGR 121-B at Drexel University taught by in Fall 2016. Since its upload, it has received 70 views. For similar materials see Computation Lab I in Engineering and Tech at Drexel University.

×

## Reviews for ENGR 121: Week 2 Lecture Notes

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/02/16
ENGR 121 B  Lecture Notes for 9/26/2016 Spencer Kociba Summary of Lecture: how to classify, categorize, modify and conduct operations using  matrices and vectors in MATLAB (which stands for Matrix Laboratory) MATRICES ● Matrix: stores a set of values of the same type ○ every value is an element ○ Matrix = m rows, n columns ● Creating Matrices ○ Ex. >> m=[ 1,4,6; 7,8,10; 2,7,15; 3,7,8] becomes a 4x3 matrix ■ 1,4,6 = 1st row, 7,8,10 = 2nd row, etc. ■ ; indicates the end of a row ■ MATLAB will show an error if your elements and the size of the matrix don’t add up ○ >>z=10*rand(3,5) becomes a 3x5 matrix with random numbers from (0,10) ○ >>z(1,2) refers to row 1, column 2 element ○ >>z(2,:) refers to all elements in row 2 ○ >>z(:,2) refers to all elements in column 2 ○ >>z([1,3], end) refers to 1st and 3rd row elements of the last  column ● Matrix Multiplication ○ Maxtrix * Matrix = New Matrix ○ In A (n x m) and B (N x M), in order to multiply A*B, m=N. To  multiply B*A, M=n ○ >>x=A*B ○ x.^(a) raises each element in matrix x by the power of a ● Matrix functions ○ zeros(n) = nxn matrix of zeros ○ zeros(n,m) = nxm matrix of zeros ○ ones(n) =  nxn matrix of ones ○ ones(n,m) = nxm matrix of ones ○ **these functions only work for 0s and 1s (there’s no  sixes(n,m) function) VECTORS ● Row vector = 1 row, n columns (1xn) ● Column vector = 1 column, n rows(nx1) ● Generating vectors ○ “Colon operator” ■ >>x=2:1:7 generates an output [2 3 4 5 6 7] ● 2=starting number (min),  1=increment, 7=ending number (max) ○ Linspace  ■ (linearly spaced vector (similar to the colon  operator) ■ >>x=linspace(­5,1,5) ● ­5=min, 1=max, 5=number of  elements in the vector (will be equally spaced between the  range of ­5 to 1) ● Accessing and modifying vectors ○ x(2) refers to element 2 in vector x ■ ****MATLAB starts counting at 1, not 0 (different from other programming languages) ○ y(1:4) refers to elements 1,2,3 and 4 of vector y ○ z([1 3 5]) refers to elements 1,3 and 5 of vector z ○ x(1)=10 changes the first element of vector x to 10 ○ In a vector x that is 1xn… ■ x(n+1)=­1 creates an additional column and  assigns ­1 to it ■ x(n+4)=6 creates an n+4th column and assigns  6 (the columns between n and n+4 are created and are assigned 0) ○ Dot product ■ <a,b,c>  ∙ <d,e,f> = ad+be+cf ■ IF YOU ARE DOING AN ELEMENT BY  ELEMENT MULTIPLICATION… ● Z.*Y ○ The period tells  MATLAB to perform operation element by element GENERATING PLOTS ● Plots are professional looking, great for inserting into data reports, research  papers, design briefs, etc. ● Commands ○ >>x=­pi:2*pi/20:pi where the range is (­pi, pi) with increments  of 2*pi/20 ○ >>y=sin(x) ○ >>figure ←this just gives you a blank canvas for plotting (optional) ○ >>plot(x,y, ‘b+’) ←b+ means “symbols on plot are blue ‘+’s” ○ ● Plotting Multiple functions on the same plot ○ >>x=0:2*pi/128:2pi  ○ >>y=sin(x) ○ >>z=cos(x) ○ >>plot(x,y, ‘ro’) ○ >>hold on ← This holds onto the same canvas to do one plot ○ >>plot(x,z, ‘b+’) ■ Extra add ons ■ legend(‘sin’, ‘cos’)   gives plot a legend ■ xlabel(‘x’)   gives x axis label a label ■ ylabel(‘cos or sin’)   gives y axis label a label ■ title(‘_____’)    gives plot a title ○

×

×

×

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Kyle Maynard Purdue

#### "When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the material...plus I made \$280 on my first study guide!"

Bentley McCaw University of Florida

Forbes

#### "Their 'Elite Notetakers' are making over \$1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.