Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Solve the following problems by writing m-scripts and using cell mode to create

ID: 2266640 • Letter: S

Question

Solve the following problems by writing m-scripts and using cell mode to create separate sections for each problem. After the problems have been completed, use the publish tool to generate a report. Print out the report and submit the exam. Two gymnasts are competing with each other. Their scores are shown in Table 8.7. Table 8.7 Gymnastics Scores Event Gymnast 1 Pommel horse Vault Floor Rings High bar Parallel bars 9.821 9.923 9.624 9.432 9.534 9.203 Gymnast 2 9.700 9.925 9.83 9.987 9.354 9.879 (a) Write a program that uses find to determine how many events each gymnast won. (b) Use the mean function to determine each gymnast's average score. 2. Suppose the following matrix represents the number of saws ordered from your company each month over the last year. saws = [1,4,5,3,7,5, 3, 10, 12, 8, 7, 4) All the numbers should be zero or positive. (a) Use an if statement to check whether any of the values in the matrix are invalid. (Evaluate the whole matrix at once in a single if state- ment.) Send the message "All valid" or else "Invalid number found" to the screen, depending on the results of your analysis. (b) Change the saws matrix to include at least one negative number, and check your program to make sure that it works for both cases.

Explanation / Answer

Question1:


%part a
gym1 = [9.821 9.923 9.624 9.432 9.534 9203];
gym2 = [9.7 9.925 9.83 9.987 9.354 9.879];
idx1 = find(gym1>gym2);%gives the indexes where gym1 is > gym2
count1 = length(idx1);%gives the number of times when gymnast 1 won
idx2 = find(gym2>gym1);%gives the indexes where gym2 is > gym1
count2 = length(idx2);%gives the number of times when gymnast 2 won

%part b
%calculating mean
gym1_mean = mean(gym1);
gym2_mean = mean(gym2);

Command window output:

Question 2:

saws = [1 4 5 3 7 5 3 10 12 8 7 4 -10];
if saws>=0
disp('All valid');
else
disp('Invalid number found');
end

it displays

if we run

saws = [1 4 5 3 7 5 3 10 12 8 7 4];
if saws>=0
disp('All valid');
else
disp('Invalid number found');
end

it displays

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote