Q:

Write a script that will do the following. Create two vectors with 20 random integers in each; in one the integers should range from 1 to 5, and in the other, from 1 to 500 (inclusive)

0

Write a script that will do the following. Create two vectors with 20 random integers in each; in one the integers should range from 1 to 5, and in the other, from 1 to 500 (inclusive). For each vector, would you expect the mean and median to be approximately the same? Would you expect the standard deviation of the two vectors to be approximately the same? Answer these questions, and then use the built-in functions to find the minimum, maximum, mean, median, standard deviation, and mode of each. Do a histogram for each in a subplot. Run the script a few times to see the variations.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch14Ex3.m

vec1 = randi([1 5],1,20);

vec2 = randi([1 500],1,20);

disp('For vector 1 with a range from 1-5:')

fprintf('The minimum is %d\n', min(vec1))

fprintf('The maximum is %d\n', max(vec1))

fprintf('The mean is %.1f\n', mean(vec1))

fprintf('The median is %.1f\n',median(vec1))

fprintf('The std deviation is %.1f\n', std(vec1))

fprintf('The mode is %.1f\n', mode(vec1))

disp('For vector 2 with a range from 1-500:')

fprintf('The minimum is %d\n', min(vec2))

fprintf('The maximum is %d\n', max(vec2))

fprintf('The mean is %.1f\n', mean(vec2))

fprintf('The median is %.1f\n',median(vec2))

fprintf('The std deviation is %.1f\n', std(vec2))

fprintf('The mode is %.1f\n', mode(vec2))

subplot(1,2,1)

hist(vec1)

subplot(1,2,2)

hist(vec2)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now