Use fprintf to display answers Random numbers in computing would often be more a
ID: 3876276 • Letter: U
Question
Use fprintf to display answers
Random numbers in computing would often be more accurately referred to as "pseudorandom numbers"-sequences of numbers whose properties only approximate the properties of sequences of random numbers. Put the following lines of code in your script file to create arrays of pseudorandom numbers (these will actually be the same pseudorandom numbers that someone else would get by running these same lines) 9. rng(1); % the argument (1) is called the 'seed'; it tells the algorithm where to start A = rand(101,20); B - rand(8,8); Now calculate the following: The average value of A The maximum value of A and the index at which it occurred (one command) Create an array, C, that is identical to A except that: any elements of A that are less than 7 are assigned a value of 7 in C. (See MATLAB help on max) The average of each column of B (one command for all 8 values) a. b. c. d. ENGR 1221 Array Operations Designed to test skills with: element-wise operations, array transposition, vertical/horizontal array concatenation, array arithmetic, and built-in math functions. The sum of each row of B (one command for all 8 values) e. f. The median of the array of medians calculated for each row of B. (1 value) This problem tests "extraction from arrays" and covers a previous concept, "using functions on arrays." How do you figure out which functions to use? How to you figure out how to use each function? What other ways can you figure out how to use each function?Explanation / Answer
Question 9:
PART a)
Average value of A-
mean(A); % Average can be calculated using the function mean.
ans = 6.3000
PART b)
Find maximum value of A and its index
Command-
[M,I] = max(A); % command will display the max number in array along with its index.
PART c)
Creating another array C from array A on given condition-
Command-
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.