1 / 11

Introduction to Programming in MATLAB

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 . Relational Operators.

bedros
Download Presentation

Introduction to Programming in MATLAB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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.

  2. Relational Operators

  3. Relational Operators • 4 < 5 true (1) • 4 <= 5 true (1) • 4 == 5 false (0) • 4 ~= 5 • 4 > 5 false (0) • 4 >= 4 • ‘A’ < ‘B’ (a) true (1) (b) false (0) (c) other/error (a) true (1) (b) false (0) (c) other/error (a) true (1) (b) false (0) (c) other/error

  4. Why would we want to test “<“ between a number and a matrix? >> im = imread(‘rainbow.jpg’); >> g = im(:,:,2); >> result = g > 200; • What type of variable will result be after the assignment? What does this code do, conceptually? • Increases the amount of green in the image • Identifies pixels with high green value • Removes green layer from the image • None/more than one/MATLAB error

  5. A new data type for variables!

  6. LOGICAL Operators

  7. Why would we want to test “<“ between a number and a matrix? >> im = imread(‘rainbow.jpg’); >> result = im(:,:,1) > 200 & im(:,:,2) > 200 & im(:,:,3) > 200; • First, take each part by itself and figure out what it does; then combine the parts. What does this code do, conceptually? • Identifies pixels that have high red, or high blue, or high green value(s) • Identifies pixels that are close to black • Identifies pixels that are close to white • Error

  8. Can you write code for the other answer choices? >> im = imread(‘rainbow.jpg’); >> result = im(:,:,1) > 200 & im(:,:,2) > 200 & im(:,:,3) > 200; • Identifies pixels that have high red, or high blue, or high green value(s) • Identifies pixels that are close to black

  9. “Green screen” special effects • Actors or other objects are filmed in front of a screen with a very specific shade of green • Later, a computer program checks the color of each pixel of the movie • Pixels matching that specific shade of green are replaced with pixels from another image/movie • Pixels not matching that specific shade of green are left alone

  10. “Green screen” special effects • Actors can wear green and be invisible in the final movie • The two men on the left are moving a puppet • The man on the right, if he doesn’t put his green shirt back on, will appear to be a floating torso

More Related