Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Courses & Content LMS Integration Documentation & Support Spring 2021 Intro to Scientific Computing > MGHW2: For loops, dot operator, plotting > ~ Averaging random
Courses & Content LMS Integration Documentation & Support Spring 2021 Intro to Scientific Computing > MGHW2: For loops, dot operator, plotting > ~ Averaging random integers 1 solution submitted (max: 10) | View my solutions The command randi(10,20,1) creates a 20 x 1 array of random integers from 1 up to 10. Create an array of 1000 random integers from 1 to 50 and store it in the variable x. Then use a for loop to find the average value of the integers in the array. Store the result in a variable called avg. In your own Matlab (outside grader), try running this over again a few times with a different starting point for the random number generator. Are you getting averages close to what you expect? Need more practice with this? Here are some free resources: Matlab Onramp, do section 13.3: https://www.mathworks.com/learn/tutorials/matlab-onramp.html TutorialsPoint: https://www.tutorialspoint.com/matlab/matlab_loops.htm Office hours-- you're always welcome. Script C Reset O MATLAB Documentation 1 rng(600); % set the random number generator so everyone gets the same result 2 x = randi (50, 1000,1) 3 4 for x 5 X = mean(x) 6 7 8 Run Script
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started