Generate two vectors (A and B) containing 100 randomly generated integer numbers
ID: 3620971 • Letter: G
Question
Generate two vectors (A and B) containing 100 randomly generated integer numbers from 0 to 10. Start the random number generation from state 0. That is use rand('state',0) before you start generating random numbers. Compute the following:
*The number of times the sum of A and B are greater than 10.
*The number of times the elements in A are less than corresponding elements in B.
Explanation / Answer
rand('state',0) A=ceil(10*rand(1,100)); B=ceil(10*rand(1,100)); %%*The number of times the sum of A and B are greater than 10. C=(A+B)>10; numberOfTimes=sum(C); fprintf('The number of times the sum of A and B are greater than 10 = %3.0f ',numberOfTimes) %%*The number of times the elements in A are less than corresponding elements in B. D=ARelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.