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

MATLAB Cable car times: Student teams competed in a cable car competition and re

ID: 3696373 • Letter: M

Question

MATLAB

Cable car times: Student teams competed in a cable car competition and recorded their times to race across a 50 m test cable. The following times were recorded (in seconds):

8.50, 12.67, 13.50, 9.28, 10.05, 10.67, 10.05, 19.83, 15.44, 17.59, 9.77, 8.88,

(add 24 more values distributed between 5.00 and 20.00)

A) Enter the values above into Notepad in a format so that they can be read into a single

column vector or row vector. Save the text file using your last name and the problem

number for the file name.

B) Write a MATLAB program to read the text file and use functions in MATLAB to find and

display each of the following (including units). The program should work for a file with any number of values (not just for 36).

Average time

Median time

Mode

Standard deviation

Number of cable car runs recorded tested

Standard deviation

Maximum time

Minimum time

C) Display the original times (4 per line) with a descriptive heading

D) Sort the times from smallest to largest and display them again (4 per line) with a descriptive

heading.

Explanation / Answer

fileID = fopen('nums1.txt','r');
formatSpec = '%f';
A = fscanf(fileID,formatSpec)
fclose(fileID);

% Average time
Avg = mean(tsobj)

% Median time
Me = median(A)

% Mode
Md = mode(A)

% Standard deviation
SD = std(A)

% Number of cable car runs recorded tested
sz = size (A)

% Standard deviation (repeated)
SD = std(A)

% Maximum time
Mx = max(A)

% Minimum time
Mn = min(A)