Question: Begin a new script and start a new code cell for Problem 1 by using 88. Use rand to create an 8 x7 matrix
Begin a new script and start a new code cell for Problem 1 by using 88. Use rand to create an 8 x7 matrix A of random numbers in the range [0, 1]. (i) In one line of code, change rows 3 and 6 of A to two. (ii) Next, use one line of code to change columns 2 through 5 of A to three. (iii) Next, use one line of code to change elements of A that are in odd numbered rows and in even numbered columns to 0.5 (i.e. A(1,2), A(1,4), A(1, 6)..) (iv) Finally, use for loops and if statements to change all elements in A that are less than 0.5 to zero. Hint: Do a help search on size, :, for, if
Step by Step Solution
3.31 Rating (151 Votes )
There are 3 Steps involved in it
clear all clear clc create an 8x7 matrix A of random numbers within the range0 1 A rand8 7 dispA fprintf change the rows 3 and 6 of A to two A36 2ones... View full answer
Get step-by-step solutions from verified subject matter experts
