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

A lab instrument generates 25 data points (as negative or positive inetgers) eve

ID: 3820191 • Letter: A

Question

A lab instrument generates 25 data points (as negative or positive inetgers) every minute. This data is captured in a file that represents every minutes reading as a 5 x 5 table, e.g. here is the data for 2 minutes:

14 32 39 41 56

59 1 19 19 53

23 37 47 49 29

66 1 24 25 56

62 73 13 22 51

12 65 50 30 23

26 53 38 11 1

35 19 15 66 14

26 22 60 33 36

48 33 3 -3 41

Each data file contains data for 100 minutes of time.

in order to analyze the data it must first be nromalized.. Data is normalized to all positive values by adding the absolute value of the smallest value in the data set (call this abs(s)) to all the values in the set; this will have the effect of shifting all data by the value abs(s).

the data file can be found at the URL below:

http://liberty.egr.vcu.edu/~resler/lab10spring16.dat

input your data from the standaed input via redirection in the command line.

You are to complete the following program by writing all of the needed functions; you can use the definition for SIZE and TIME as needed in your functions.

#include <stdio.h>
#include <stdlib.h>

#define SIZE 5
#define TIME 100

int inputData(int [][SIZE][TIME]);
// inputs the data, returns the number of items read in

void printDataAtTime(int [][SIZE][TIME]);
// Outputs the SIZE x SIZE table at time t

void printSampleData(int [][SIZE][TIME]);
// Prints the SIZE x SIZE able at time 0 and time TIME-1

int normalize(int [][SIZE][TIME});
// Normalizes the data and returns the shift amount


int main (void) {

int data[SIZE][SIZE][TIME];
  
printf("count = %d ", inputData(data));
  
printf(" Sample of data: ");
printfSampleData(data);
  
printf(" shift = %d ", normalize(data));
  
printf(" Sample of data after shift: ");
printSampleData(data);
  
return(0);
}

liberty: /cprogs/96 a.out lab1 Fall15. dat count 2500 Sample of data 14 32 39 41 56 59 1 19 19 53 23 37 47 49 29 66 1 24 26 54 62 73 13 22 51 62 0 29 50 32 28 25 45 46 61 32 11 3 5-5 66 38 35 38 35 39 35 3 46 56 shift Sample of data after shift: 23 41 48 50 65 68 10 28 28 62 32 46 56 58 38 75 10 33 35 63 71 82 22 31 60 71 9 38 59 41 37 34 54 55 70 41 20 12 14 4 75 47 44 47 44 48 44 12 55 65 liberty: /cprogs/96 I

Explanation / Answer

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define SIZE 5

//change to 2 from 100 if you want to test for 2 min
#define TIME 100
int inputData(int[][SIZE][TIME]);
// inputs the data, returns the number of items read in
void printDataAtTime(int[][SIZE][TIME]);
// Outputs the SIZE x SIZE table at time t
void printSampleData(int[][SIZE][TIME]);
// Prints the SIZE x SIZE able at time 0 and time TIME-1
int normalize(int[][SIZE][TIME]);
// Normalizes the data and returns the shift amount

int main(void) {
   int data[SIZE][SIZE][TIME];

   printf("count = %d ", inputData(data));

   printf(" Sample of data: ");
   printSampleData(data);

   printf(" shift = %d ", normalize(data));

   printf(" Sample of data after shift: ");
   printSampleData(data);

   return(0);
}

// inputs the data, returns the number of items read in
int inputData(int a[][SIZE][TIME])
{
   int count = 0;
   for (int k = 0; k < TIME; k++)
       for (int i = 0; i < SIZE; i++)
       {
           for (int j = 0; j < SIZE; j++)
           {
               scanf("%d", &a[k][i][j]);
               count++;
           }
       }
   return count;
}

// Outputs the SIZE x SIZE table at time t
void printDataAtTime(int a[][SIZE][TIME])
{
   for (int k = 0; k < TIME; k++)
   {
       printf("For %d minute: ", k + 1);
       for (int i = 0; i < SIZE; i++)
       {
           for (int j = 0; j < SIZE; j++)
           {
               printf("%d ", a[k][i][j]);

           }
           printf(" ");
       }
       printf(" ");
   }
}

// Prints the SIZE x SIZE able at time 0 and time TIME-1
void printSampleData(int a[][SIZE][TIME])
{
   for (int k = 0; k < TIME; k++)
   {
       printf("For %d minute: ", k + 1);
       for (int i = 0; i < SIZE; i++)
       {
           for (int j = 0; j < SIZE; j++)
           {
               printf("%d ", a[k][i][j]);

           }
           printf(" ");
       }
       printf(" ");
   }
}
// Normalizes the data and returns the shift amount
int normalize(int a[][SIZE][TIME])
{
   int min = 0;
   //find out min value
   for (int k = 0; k < TIME; k++)
   {
      
       for (int i = 0; i < SIZE; i++)
       {
           for (int j = 0; j < SIZE; j++)
           {
               if (min > a[k][i][j])
               {
                   min = a[k][i][j];
               }

           }
          
       }
      
   }
   //shift by minimum value by adding absolute value of the number
   int abs_min = abs(min);
   for (int k = 0; k < TIME; k++)
   {
      
       for (int i = 0; i < SIZE; i++)
       {
           for (int j = 0; j < SIZE; j++)
           {
              
               a[k][i][j] += abs_min;
           }
          
       }
      
   }
   return abs_min;
}

---------------------------------

//output

count = 50

Sample of data:
For 1 minute:
-2 10 48 1 39
48 1 39 67 18
39 67 18 59 43
18 59 43 65 30
43 65 30 53 22


For 2 minute:
30 53 22 59 -2
22 59 -2 37 58
-2 37 58 33 19
58 33 19 59 65
19 59 65 31 2

shift = 2

Sample of data after shift:
For 1 minute:
0 12 52 5 45
52 5 45 71 24
45 71 24 63 49
24 63 49 69 36
49 69 36 57 28


For 2 minute:
36 57 28 63 4
28 63 4 41 64
4 41 64 37 25
64 37 25 63 69
25 63 69 33 4

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