Iterate through the vector a using a while loop and return


You must use either for or while to solve the following problems.

a. Iterate through a vector, A, using a for loop and create a new vector, B, containing logical values. The new vector should contain true for positive values and false for all other values.
For example, if

2278_d8277927-d4ad-4f67-9d10-422c93fe0a09.png

b. Iterate through the vector, A, using a while loop and return a new vector, B, containing true for positive values and false for all other values.

c. Iterate through a logical array, N, using a for loop and return a new vector, M, containing the value 2 wherever an element of N is true and the value -1 (not a logical value) wherever N is false. For example, if
N = [true false false true true false true] the result should
be M = [2 -1 -1 2 2 -1 2]

d. Iterate through an array, Z, using a while loop. Replace every element with the number 3 until you reach a number larger than 50. Leave the rest unchanged. For example, if
Z = [4 3 2 5 7 9 0 64 34 43], after running your script,
Z = [3 3 3 3 3 3 3 3 34 43]

 

 

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Iterate through the vector a using a while loop and return
Reference No:- TGS01606094

Expected delivery within 24 Hours