Question

6107 H Baseball Statistics 2 You are given the file Baseball.mat that contains a BattingStats. Each row of this array corresp solve with Matlab! many thankss
Also this is what the file Baseball look like, Its a 100x10 array

Editor - lecture5.m Variables- BattingStats X W BattingStats 100x10 double Na 1 2 3 4 6 7 8 0.2660 1 0.1720 0.2330 0.1110 0.3
6107 H Baseball Statistics 2 You are given the file Baseball.mat that contains a BattingStats. Each row of this array corresponds to the batting averages of one baseball player and each column corresponds ticular year. Hence, the value of the (3,4) - element corresponds to the third player's batting average during year 4. two-dimensional array named to the batting averages during a par- Write a one-line MATLAB command to manipulate this array in each of the sub- problems below. You should use the MATLAB functions max, min and mean to do so. (a) Find the highest batting average for each year and the player who achieved it. Store this information in the two-row array bestAverageofYear, where the first row contains the batting average and the second row the player number. (b) Find the highest batting average over all years and store the result in the variable bestAverage. (c) Find the mean batting average over all players for the 4th year and store the result in the variable fourthYearAverage. (d) Find the lowest batting average for each year and the player who achieved it. Store this information in the two-row array worstAverageof Year, where the first row contains the batting average and the second row the player number. (e) Find the lowest batting average over all years and store the result in the variable worstAverage.
Editor - lecture5.m Variables- BattingStats X W BattingStats 100x10 double Na 1 2 3 4 6 7 8 0.2660 1 0.1720 0.2330 0.1110 0.3030 0.2300 0.1780 0.2220 0.3370 0.2410 0.2770 0.2590 0.3760 0.1960 0.2340 0.4040 3 0.2320 0.1640 0.3000 0.1100 0.3420 0.1240 0.1560 0.2760 0.2430 4 0.2670 0.3300 0.1330 0.1870 0.1280 0.2250 0.3780 5 0.2980 0.4080 0.3350 0.2430 0.4030 0.2250 0.1560 0.2490 6 0.3850 0.3340 0.2210 0.2400 0.1110 0.1910 0.3660 0.1040 7 0.1500 0,4040 0.2330 0.2710 0.2010 0.1950 0.2810 0.2930 8 0.3220 0.1730 0.3970 0.3500 0.4020 0.1320 0.2160 0.1710 0.2790 0.2640 0.2780 0.3170 0.2130 0.2840 0.1680 0.2640 10 0.2340 0.1150 0.3640 0.3710 0.1960 0.1870 0.1680 0.3250 11 0.3740 0.3350 0.1850 0.1160 0.1370 0.1480 0.2620 0.2880 12 0.2410 0.3450 0.4040 0.4120 0.3650 0.3830 0.3210 0.3420 13 0.1550 0.3660 0.2820 0.2420 0.1420 0.1880 0.3300 0.2340 14 0.2960 0.4070 0.3990 0.3980 0.2030 0.2710 0.1210 0.1750 15 0.2940 0.3890 0.1260 0.3450 0.3790 0.3700 0.3630 0.2330 16 0.2010 0.2270 0.2550 0.2400 0.2550 0.1130 0.3110 0.1030 17 0.3490 0.1000 0.2620 0.2030 0.2910 0.3810 0.1420 0.2890 18 0.4100 0.2680 0.1280 0.1180 0.2810 0.1400 0.3660 0.3970 19 0.4050 0.1640 0.3810 0.3300 0.3170 0.3590 0.1620 0.1290 20 0.1390 0.1680 0.3750 0.2570 0.1090 0.3480 0.2880 0.1110 Nmt EEKHK#K
0 0
Add a comment Improve this question Transcribed image text
Answer #1

% Matlab commands to manipulate the array and find the required results

% a. Finds the maximum batting average for each year(across columns) in bestAverageYear(1,:)
% and return the index of the player who achieved it in bestAverageYear(2,:)
[bestAverageYear(1,:),bestAverageYear(2,:)] = max(BattingStatus);

% display the result
disp(bestAverageYear);

%b. Finds the highest batting average over all the years
% max(BattingStatus) returns the maximum value column wise and
% max(max(BattingStatus)) returns the maximum value among the values
% returned by max(BattingStatus)
bestAverage = max(max(BattingStatus));

% display the result
disp(bestAverage);

%c. Finds the mean Batting average for all players for 4th year
fourthYearAverage = mean(BattingStatus(:,4));

% display the result
disp(fourthYearAverage);

%d. Finds the minimum batting average for each year(across columns) in worstAverageYear(1,:)
% and return the index of the player who achieved it in worstAverageYear(2,:)
[worstAverageYear(1,:),worstAverageYear(2,:)] = min(BattingStatus);

% display the result
disp(worstAverageYear);

%e. Finds the lowest batting average over all the years
% min(BattingStatus) returns the minimum value column wise and
% min(min(BattingStatus)) returns the minimum value among the values
% returned by min(BattingStatus)
worstAverage = min(min(BattingStatus));

% display the result
disp(worstAverage);

Add a comment
Know the answer?
Add Answer to:
solve with Matlab! many thankss Also this is what the file Baseball look like, Its a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT