MATLAB
The following are three vectors representing the age (years), height (cm) and weight (kg) of ten girls.
A = [ 12 13 13 14 16 14 15 12 13 12];
H = [143 158 161 150 159 159 150 144 157 137];
W = [ 39 48 49 42 51 51 47 31 43 31];
a) Calculate the average of all vectors (age, height and weight). Put all three means in a column vector named mean_ahw. (Use function mean to calculate the averages.)
b) How many girls in the group are taller than 150cm? Put the result in a variable named n150.
c) What is the average weight of girls of age 13 or younger? Put the result in a variable named mw13.
d) How many girls are taller than the average and at the same time have weight below the average? Put the result in a variable named ntall.
e) Is the oldest girl also the tallest? Write the code so that it is checking whether the index of the oldest girl is compared with the index of the tallest one. Put your result in a variable named age_height_check, which should have a value 0 (for false) or 1 (for true). (For finding the oldest/tallest girl use function max.)
Please give thumbs up, thanks
Sample output:
code:
A = [ 12 13 13 14 16 14 15 12 13 12];
H = [143 158 161 150 159 159 150 144 157 137];
W = [ 39 48 49 42 51 51 47 31 43 31];
%a
mean_ahw(1)=mean(A);
mean_ahw(2)=mean(H);
mean_ahw(3)=mean(W);
%b
n150=sum(H>150)
%c
mw13=mean(W(A<=13))
%d
sum(H>mean(H))+sum(W<mean(W))
%e
find(A==max(A))==find(H==max(H))
Get Answers For Free
Most questions answered within 1 hours.