CodeCodeCode

ENGR132: HW07 - class6a_activity3

May 6th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.81 KB | None | 0 0
  1. %  Program Description: Generate 1000 Gaussian random numbers with a mean
  2. %  of 80 and standard deviation of 5 and makes a histogram out of the data.
  3.  
  4. % --- INPUTS ---
  5. %Generates 1000 random numbers with mean 80 and stdev 5 in a 1000 by 1
  6. %matrix.
  7. rnd_num = normrnd(80,5,1000,1);
  8.  
  9. % --- CALCULATIONS ---
  10. %Finds the mean of the data.
  11. fprintf('\nMean of data: %f\n', mean(rnd_num));
  12. %Finds standard deviation of data.
  13. fprintf('Standard Deviation of data: %f\n', std(rnd_num));
  14.  
  15. %Finds the frequency of each bin and the center of each bin.
  16. [Bin_frequency, Bin_centers] = hist(rnd_num)
  17.  
  18. %Sorts the random numbers.
  19. sort(rnd_num);
  20.  
  21. % --- OUTPUTS ----
  22. %Creates a histogram based on the given data.
  23. hist(rnd_num);
  24. title('Distribution of random 1,000 numbers');
  25. xlabel('Value of number');
  26. ylabel('Frequency');
  27. grid;
Advertisement
Add Comment
Please, Sign In to add comment