Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

Similar presentations


Presentation on theme: "Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike."— Presentation transcript:

1 Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at www.peerinstruction4cs.org.Dr. Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org 1

2 EXPRESSIONS Express yourself 2

3 Which expression does NOT give the same answer as the others? a)a * b + c * d b)(a * b + c * d) c)a * (b + c) * d d)(a * b) + (c * d) e)None or more than one of the above 3

4 ASSIGNMENTS (not the homework kind) 4

5 Which of the following is the result of running this code: >> a = 6; >> b = 3; >> a = b; >> b = 5; a)The value of the variable a is the character ‘b’, and the value of variable b is 5 b)The value of variable a is 5 and the value of variable b is 5 c)The value of variable a is 3 and the value of variable b is 5 d)MATLAB will give an error e)None or more than one of the above 5

6 What is a variable? Variables are like labeled boxes Assignment (=) puts something in the box Assigning one variable to another copies what was in one box and places a copy in the other box Always copies values from right to left 6

7 Which of the following is the result of running this code: >> a = 6; >> b = 3; >> a = b; >> b = a; a)The value of variable b is the character ‘a’ and the value of the variable a is the character ‘b’ b)The value of variable a is 6 and the value of variable b is 3 c)The value of variable a is 3 and the value of variable b is 6 d)MATLAB will give an error e)None or more than one of the above 7

8 COLORS IN THE COMPUTER Taking a peek behind the wizard’s curtain 8

9 To a computer, everything is numbers Everything. 9 What we perceiveWhat it is to the computer Numbers WordsNumbers ColorsNumbers PicturesNumbers SoundsNumbers VideoNumbers Pushing buttons on the keyboard or mouse Numbers Facebook status updateNumbers

10 Colors in the computer The RGB Color scheme is a way for the computer to represent colors as numbers RGB stands for Red, Green, and Blue All colors in the computer are made by combining different amounts of red, green and blue – In other words, each color is represented by a vector of three numbers: 1 st number says how much red 2 nd number says how much green 3 rd number says how much blue – Each number can be between 0 and 255 10

11 RGB Color mixing Note that when all the colors are combined, the result is white – Not like paint! (brown or black when combined) This picture doesn’t show all the possibilities – Doesn’t show gradations of mixing (little red with a lot of blue, etc) – Doesn’t show gradations of intensity within a given shade (light pink vs dark pink, greys between white and black) 11

12 Which of these colors is produced by the RGB code 255 255 50? 12 Hint: a) c) b) d) e) None/other/error

13 About this class When you use MATLAB later on in scientific applications, you will be working with numbers If you work with images in this class, will you be prepared to work with that numeric data? – Yes! It’s the same skills, because… To a computer, everything is numbers. – Why not practice with matrices of numbers, that just happen to be images? 13


Download ppt "Introduction to Programming in MATLAB Intro. MATLAB Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike."

Similar presentations


Ads by Google