You are working for a data analytics firm that has been aske

You are working for a data analytics firm that has been asked to create a generic data collection tool that will provide basic statistics on input typed in to the screen. This data collection tool should ask the user to type the number of desired data points they need to record, the number of decimal places for all of the numbers displayed in the final output, then the program should allow them to record all of the data points into the Command Window, one by one, where the user presses the Enter key after each data point. You may assume that this program will only need to handle numeric values and will not need to worry about strings, vectors, or input of other variable types. As soon as the user inputs all of the values, your program should generate a string representation of the vector of data, as well as provide basic statistics including the number of negative values, number of positive values, the sum of all of the values, the mean, median, and standard deviation of the data set, and the minimum and maximum values in the data set. The output should appear similar to the output shown below. Note that the vector of data does not need to be displayed with the number of decimal places specified by the user. Sample Input/Output: Type the number of data points to record: 4 Type the number of decimal places to show in output: 2 Data Point #1: 8 Data Point #2: 2 Data Point #3: 6 Data Point #4: 4 Data Set Information: Vector = [8 2 6 4] # Negative: 0.00 # Positive: 4.00 Minimum: 2.00 Maximum: 8.00 Sum: 20.00 Mean: 5.00 Median: 5.00 Standard Deviation: 2.58

Solution

numberOfPoints = input(\'Type the number of data points to record: \');
decimalPlaces = input(\'Type the number of decimal places to show in output: \');

negatives = 0;
positives = 0;

vector = zeros(numberOfPoints,1);
for i=1:numberOfPoints
    fprintf(\'Data Point #%d: \',i);
    vector(i,1) = input(\'\');
    if vector(i,1) < 0
        negatives = negatives + 1;
    elseif vector(i,1) > 0
        positives = positives + 1;
    end
end

fprintf(\'\ Data Set Information:\ \ \');
fprintf(\'Vector = [\');
for i=1:numberOfPoints
    if i==1
        fprintf(\'%d\',vector(i,1));
    else
        fprintf(\' %d\',vector(i,1));
    end
end
fprintf(\']\ \ \');
fprintf( strcat(strcat(\'# Negative: %.\',int2str(decimalPlaces)),\'f\ \'), negatives);
fprintf( strcat(strcat(\'# Positive: %.\',int2str(decimalPlaces)),\'f\ \'), positives);
fprintf(\'\ \');
fprintf( strcat(strcat(\'Minimum: %.\',int2str(decimalPlaces)),\'f\ \'), min(vector));
fprintf( strcat(strcat(\'Maximum: %.\',int2str(decimalPlaces)),\'f\ \'), max(vector));
fprintf(\'\ \');
fprintf( strcat(strcat(\'Sum: %.\',int2str(decimalPlaces)),\'f\ \'), sum(vector));
fprintf( strcat(strcat(\'Mean: %.\',int2str(decimalPlaces)),\'f\ \'), mean(vector));
fprintf( strcat(strcat(\'Median: %.\',int2str(decimalPlaces)),\'f\ \'), median(vector));
fprintf( strcat(strcat(\'Standard Deviation: %.\',int2str(decimalPlaces)),\'f\ \'), std(vector));

   

 You are working for a data analytics firm that has been asked to create a generic data collection tool that will provide basic statistics on input typed in to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site