Using Pointers and Arrays to Compare Files?

So I have an assignment where I need to compare three different input channels with a reference signal and output a file with the classification at the end of the program. I have done some work with arrays before but for whatever reason I am running into problems with it this time. I have a long list of variables to keep track of myself. I am using Euclidean Distance to classify the strength of signal so I want to find the square root of the sum of distances between the two. I'm using the cout at the bottom to make sure that my difference1sum is correct but it's printing "0" and nothing else. Is there a problem with my arrays here? Or is this okay (if that's the case it may not be reading my file?)

Any help you could offer would be extremely appreciated.

Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <fstream>
using namespace std;

int arrayMax=57;
int channel1input[57];
int channel2input[57];
int channel3input[57];
int referencesignal[57];
int channel1difference[57];
int channel2difference[57];
int channel3difference[57];
int difference1squared[57];
int difference2squared[57];
int difference3squared[57];
int difference1sum=0;
int difference2sum=0;
int difference3sum=0;
int channel1sqrt;
int channel2sqrt;
int channel3sqrt;
int channel1outputclass;
int channel2outputclass;
int channel3outputclass;


int main()
{
	ifstream ReferenceFile, channel1file, channel2file, channel3file;
	ReferenceFile.open("ReferenceSignal.txt");
	channel1file.open("Channel_1_Output.txt");
	channel2file.open("Channel_2_Output.txt");
	channel3file.open("Channel_3_Output.txt");


		for (int i=0; i<arrayMax; i++)
		{
			ReferenceFile >> referencesignal[i];
		}

		for (int i=0; i<arrayMax; i++)
		{
			channel1file >> channel1input[i];
		}

		for (int i=0; i<arrayMax; i++)
		{
			channel2file >> channel2input[i];
		}

		for (int i=0; i<arrayMax; i++)
		{
			channel3file >> channel3input[i];
		}

		for (int i=0; i<arrayMax; i++)
		{
			channel1difference[i] = (channel1input[i] - referencesignal[i]);
		}
			
		for (int i=0; i<arrayMax; i++)
		{
			difference1squared[i] = channel1difference[i] * channel1difference[i];
			
			difference1sum += difference1squared[i];
		}
		
		cout<<difference1sum<<endl;

		system("pause");
			return 0;
}
Topic archived. No new replies allowed.