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

The collection of N numbers is supplied in a data file called “numbers.txt”. Ass

ID: 1715994 • Letter: T

Question

The collection of N numbers is supplied in a data file called “numbers.txt”. Assume that there are no more than 1000 numbers in the file at any time. You should read these numbers into an array (auto-adjust for size via EOF detection) and compute the smallest, largest, mean, and standard deviation using 4 separate functions with the following prototypes:

double smallest(double x[], int size);

double largest(double x[], int size);

double average(double x[], int size);

double sigma(double x[], double data_avg, int size);

Explanation / Answer

MATLAB code:


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

>> smallest=min(A)

>> largest=max(A)

>> average= mean(A)

>> standard_deviation= std(A)

for 1 to 10 numbers the output results are

smallest =

     1


largest =

    10


average =

    5.5000


standard_deviation =

    3.0277