































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































Start
k ≤ n?
Statements-
end
Statements
True False
Set k = m
Increment k by s
for Counter = Start : Increment: End
statements
end
x = [10,1000,-10,100]; y = NaN*x; for k = 1:length(x) if x(k) < 0 continue end y(k) = log10(x(k)); end
y = 1, 3, NaN, 2
B = [0, -1, 4; 9, -14, 25; -34, 49, 64] B = 0 -1 4 9 -14 25 -34 49 64
D = (B >= 0) D = 1 0 1 1 0 1 0 1 1
Mask Array → a Logical that “masks out” Negative numbers
x = -7 0 8 5 -
nn = x>=0 % the logical mask nn = 0 1 1 1 0
y = x(nn) y = 0 8 5
sqrt1 = sqrt(x(nn)) sqrt1 = 0 2.8284 2.
sqrt2 = x % make starting copy of x sqrt2 = -7 0 8 5 -
sqrt2(nn) = sqrt(sqrt2(nn)) sqrt2 = -7.0000 0 2.8284 2.2361 -2.
ONLY the Three Sq-Roots
the Three Sq-Roots AND the two NON- Roots
x = 5; while x < 25 disp(x) x = 2*x - 1; end
Start
Logical Decision
Statements (MUST Increment Loop Variable)
end
Statements
True False
Set Loop Var Initial value
k = 1 x = 9 k = 2 x = 17 k = 3 x =
y
y =
15 27 51