Chapter 4 : Programming with Matlab Flashcards

1
Q

equal to

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

not equal to

A

~=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

greater than or equal to

A

> =

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

less than or equal to

A

<=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

less than

greater than

A

<

>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

NOT

A

~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

returns an array as the same dimension as A; the new array has 1s where A is 0 and 0s where A is nonzero

A

~A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

AND

A

&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A & B

A

returns an array of the same dimension as A and B; then new array has 1s where both A and B have nonzero elements and 0s where either A or B is 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

short circuit AND

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

operator for scalar logical expressions. returns true if both A and B evaluate true, and false if they do not

A

A && B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

OR

A

|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A || B

A

operator for scalar logical expressions returns true if either A or B or both evaluate to true, and false if they do not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is the order of precedence for operator types?

A
  1. parenthesis, starting with inner most pair
  2. arithmetic operators and logical NOT; evaluated left to right
  3. relational operators evaluated from left to right
  4. logical AND
  5. logical OR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is the format for if then statements

A

if STATEMENTS EXPRESSION
STATEMENT GROUP 1
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is the format for an else statement

A
if LOGICAL EXPRESSION
STATEMENT GROUP 1
else
STATEMENT GROUP 2
end
17
Q

what is the format for an elseif statement?

A
if STATEMENTS EXPRESSION
STATEMENT GROUP 1
elseif LOGICAL EXPRESSION 2
STATEMENT GROUP 2
else
STATEMENT GROUP 3
end
18
Q

What is required after every if then statement?

A

end

except an elseif

19
Q

what is the typical structure for a loop?

A

for LOOP VARIABLE = M:S:N
STATEMENTS
end

20
Q

what does the function ‘break’ do?

A

the program execution will jump to the ‘end’