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)
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:14| Question number:3.14
All Answers
total answers (1)
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