CSE 7 Lecture Notes - Lecture 12: For Loop, Boolean Expression, Size Function

47 views3 pages

Document Summary

Cse 7 notes lecture 12 and 13: 2/6/17 &2/13/17. The single x | y means both sides will be evaluated. Single & means if either side is false then it is false, needs both to be true. General form: a question if () statement(s) end. Example: if a number is divisible by two, then it is an even number. Ex: num= input( enter an integer:"); if (mod(num,2) == 0) fprintf( the integer %d is odd. \n", num) end. Size function: >> scores = [ 1 1 1; 2 2 2 ; 3 3 3; 4 4 4 ]; >> size ( scores ) ans = 4 3. Ex: age= input( enter age:"); while age < 0 age = input( invalid! enter a positive number:"); end. For j= 1:5 vec(j)= 0 end result: vec(1)=0, vec(2)=0, vec(3)=0, vec(4)=0, vec(5)=0. >> y= [4: . 5: 20: error: dimension mismatch. >> myvec= rand(1000,2) (where 2 is the number of colors)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents