Eamonn Keogh eamonn@cs.ucr.edu CS005 Introduction to Programming: Matlab Eamonn Keogh eamonn@cs.ucr.edu.

Slides:



Advertisements
Similar presentations
Answer the following questions by moving either to the chicken or the egg side of the room.
Advertisements

FIGURATIVE LANGUAGE. #1 SIMILE A simile is one kind of figurative language. It makes a comparison of two unlike things using the words “like” or “as”.
CS 166 DATABASE MANAGEMENT SYSTEMS Dr Eamonn Keogh uci
• Would like • Would prefer • Would rather
7 th Grade Term 4 Week 2. Monday Bell Ringer Write the C & H down in your planner Write your SSID # and password in your planner Turn in your Call of.
Go Figure! Figurative Language Grades 6-8 Recognizing Figurative Language The opposite of literal language is figurative language. Figurative language.
Jan. 14, F.O.A. (Bellwork) Alliteration or assonance? Alice’s aunt ate apples and acorns around August. "Hear the mellow wedding bells" by Edgar.
1 Project 15: Animals Using Derived Classes and Inheritance.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CATALINA ISLAND FIELD TRIP March 8th- 11th
CONTENTS 5-1 Using it to talk about time 5-2 Prepositions of time
Grade 3 Language Arts Punctuation and Capitalization
GIRLS LOCKER ROOM PROCEDURES
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CSCI 203: Introduction to Computer Science I
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
Number Representation
CS005 Introduction to Programming
PRESENT SIMPLE.
CS005 Introduction to Programming
What do cats eat ? They eat … 2A : Unit 8.
UNIT 11 A1+ SHE’S REALLY FAMOUS! Part I.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CS005 Introduction to Programming:
CS005 Introduction to Programming:
ALLITERATION Definition Role of alliteration in poetry
CMSC201 Computer Science I for Majors Lecture 27 – Final Exam Review
CS005 Introduction to Programming
Welcome to the Language Lab
Figurative Language Using figures of speech to be more effective, persuasive and impactful. Figures of speech such as metaphors, similes, allusions go.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CS005 Introduction to Programming
Lap 5: Poetry Day 3 & 4.
Final Exam Review 6 December 2010.
Conditional Statements
Welcome to CIS WELCOME WELCOME WELCOME W E L C O M E.
Figurative Language.
Figurative Language Figuring it Out.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CS005 Introduction to Programming
CS005 Introduction to Programming: Matlab Eamonn Keogh
Welcome to CIS WELCOME WELCOME WELCOME W E L C O M E.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
Help! I don’t know how to revise!
CS 111 Digital Image Processing
CS005 Introduction to Programming: Matlab
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
Wed 11/1/17 Agenda Homework Anyone need to finish their test?
Logical Operations In Matlab.
Eamonn Keogh CS005 Introduction to Programming: Matlab Eamonn Keogh
CMSC201 Computer Science I for Majors Lecture 25 – Final Exam Review
Social Studies Warm-ups
Locations for CS 115 Activities
Mrs. Hunter Homework Letter October 1-5, 2018 Important Dates
PARENT INFORMATION LETTER
Talking about weekly activities
Chengyu Sun California State University, Los Angeles
Beginning of the year information
SHARING WAYS TO COPE WITH STRESS
What Family Care expects…
World’s Finest Chocolate fundraiser is underway!
Materials needed for this class:
Stouffer’s Stars April 15, 2019
Pre-Calc Monday Today is “Old Stuff” Day
Welcome to College English 1!
AUGUST 2015 Back to School Bash! Every Saturday! First Day of School!
Warmups October 6-10, 2014.
Guidance Sheet: Language – Manager of the Nursery
How to revise-simply..
Presentation transcript:

Eamonn Keogh eamonn@cs.ucr.edu CS005 Introduction to Programming: Matlab Eamonn Keogh eamonn@cs.ucr.edu

Golden Rules I >> X = 25; The only way a variable can change is if is on the left side of an assignment >> X = 25; >> A = X + 3; % Will not change X >> A = TimesFive (X) % Will not change X >> X = X + 3; % May change X

Golden Rules II < > >= <= ~= The result of any relational/ inequality test is 1 or O Relational/ inequality tests: == < > >= <= ~= >> X == 25; % Can only be 1 or 0 >> X ~= Y; % Can only be 1 or 0 >> X >= max(Y); % Can only be 1 or 0 >> X == upper(‘A’); % Can only be 1 or 0

>> upper(‘a’) == ‘A’; % Can only be 1 or 0, it is 1 >> BobsMI = ‘b’; >> upper(‘b’)’ == BobsMI; % Can only be 1 or 0, it is 0 % Can only be 1 or 0 >> IsDrunk = GetBeersConsumed >= 2;

Write a function that returns true if it begins and ends with the same letter function IsSymmetric = BookEndString(A) if A(1) == A(end) IsSymmetric = 1; else IsSymmetric = 0; end EDU>> BookEndString('eamonn') ans = EDU>> BookEndString('radar') 1 EDU>> end A e a m o n 1

Fix it to be case insensitive function IsSymmetric = BookEndString(A) if upper(A(1)) == upper(A(end)) IsSymmetric = 1; else IsSymmetric = 0; end EDU>> BookEndString(‘Radar') ans = 1

function IsRepeated = RepeatedEndLetter(A) if A(end-1) == A(end) IsRepeated = 1; else IsRepeated = 0; end Write a function that takes in a string, and returns true if the last two letters are the same EDU>> RepeatedEndLetter('eamonn') ans = 1 EDU>> RepeatedEndLetter('Reese') EDU>> RepeatedEndLetter('John Hamm') end e a m o n end -1

Write a function that takes in a string that contains two or more words, and returns true if the first two words are alliterative Alice’s aunt ate apples and acorns around August. Becky’s beagle barked and bayed, becoming bothersome for Billy. Carries cat clawed her couch, creating chaos. Dan’s dog dove deep in the dam, drinking dirty water as he dove. Eric’s eagle eats eggs, enjoying each episode of eating. Fred’s friends fried Fritos for Friday’s food. T o t e s

Looks good… but there is a bug.. function SecondWordOnwards = StripFirstWord(A) for i = 1 : length(A)-1 if A(i) == ' ' StartOfSecondWord = i + 1; end SecondWordOnwards = A(StartOfSecondWord:end); T o t e s Looks good… but there is a bug.. EDU>> StripFirstWord('Dr. Keogh') ans = Keogh

function SecondWordOnwards = StripFirstWord(A) for i = 1 : length(A)-1 if A(i) == ' ' StartOfSecondWord = i + 1; end SecondWordOnwards = A(StartOfSecondWord:end); We don’t start the second word at the first space, we start at the last space EDU>> StripFirstWord('live and let die') ans = die

Fixed! function SecondWordOnwards = StripFirstWord(A) for i = 1 : length(A)-1 if A(i) == ' ' StartOfSecondWord = i + 1; break; end SecondWordOnwards = A(StartOfSecondWord:end); Fixed! EDU>> StripFirstWord('live and let die') ans = and let die

function Alliterative = IsAlliterative(A) A = upper(A); FirstLetterFirstWord = A(1); A = StripFirstWord(A); FirstLetterSecondWord = A(1); if FirstLetterFirstWord == FirstLetterSecondWord Alliterative = 1; else Alliterative = 0; end T o t e s T O E S T T E S T T == T EDU>> IsAlliterative('To test') ans = 1 EDU>> IsAlliterative('To rest')

EDU>> StringRotation('eamonn') amonne monnea onneam nneamo neamon Write a function that takes in a string and displays it, then every rotation of it e a m o n

EDU>> StringRotation('eamonn') eamonn amonne monnea onneam Monnea decora is a species of beetle in the family Carabidae, NEAMON

e a m o n e a m o n e a m o n a m o n e A = A = A = [A(2:end) A(1)]; EDU>> StringRotation('eamonn') eamonn amonne Write a function that takes in a string and displays it, then every rotation of it A = e a m o n A = e a m o n e a m o n a m o n e A = [A(2:end) A(1)];

function dummy = StringRotation(A) disp(A) for i = 1 : length(A) A = [A(2:end) A(1)]; end

End Game Class on Monday Review session on Wed, Lead by TA (Exam on Friday? During class time) Lab on Friday afternoon (Exam on tues: 3:00 to 6:00 ) Dr. Keogh will not be here from Wed morning till late Thursday. If you want office hours, get them before then, or ask the TA.