i'm nowhere near finished with this code yet, i apologize if it looks messy, as i have tried to complete what parts i am somewhat familiar with, but in all honesty, i am completely lost. i have put my basic questions inside of the code to start. full disclosure: this is a homework assignment, and it is due by midnight tonight, i have been working on it throughout the week but have not gotten very far, so any help on this is definitely going to be appreciated.
i will post the full assignment below
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
int main()
{
int ED, CD;
ifstream channel1_file("Channel_1_output.txt");
ifstream channel2_file("Channel_2_output.txt");
ifstream channel3_file("Channel_3_output.txt");
ifstream reference_file("ReferenceSignal.txt");
//is there a means of opening all files in one statement and then having the program read them
//all and store them into seperate arrays
if (channel1_file.is_open())
{
//Do stuff here?
channel1_file.close();
}
if (channel2_file.is_open())
{
// Do stuff here?
channel2_file.close();
}
if (channel3_file.is_open())
{
// Do stuff here?
channel3_file.close();
}
if (reference_file.is_open())
{
// Do stuff here
reference_file.close();
}
void readFile(ifstream & fin, double data[]);
{
if (fin.is_open())//error=fin is undefined.......do i need to define fin as a variable even though it has a
//file association
{
double next;
for (int i = 0; fin >> next; i++)
{
data[i] = next;//error=cannot determine instance "data" is intended
}
else //error= expected a statement
{
cout << "readFile could not open the given file" << endl;
exit(EXIT_FAILURE);
}
double next;
for (int i = 0; fin >> next; i++)
{
data[i] = next;//error=cannot determine instance "data" is intended
}
double name_of_array[57];
double myEDistance(double data_arr[], double reference_arr[])
{//error= expected a ; (im not sure where though)
// Calculations go here i belive
}
//Cumululative distace (cd)=Sum of all 57 SqD = (SqD1 + SqD2 + SqD3 + ……. + SqD57)
//Euclidean Distance ( ED) = square root of Cumulative Distance (CD) => ED = sqrt(cd)
}
double sqrt_value = sqrt(some_double);
string myDecision(double euclidean_distance);
{
if (ED <= 0.5)
{
cout<<" BEST"<<endl;
}
else if (ED <= 1.0 && ED > .5)
{
cout << " GOOD" << endl;
}
else if (ED <= 3 && ED > 1.0)
{
cout << " LAST OPTION" << endl;
}
else
{
cout<<" NO GOOD (do not use)"<<endl;
}
//These ED decisions are supposed to be the output(decision_1/decision_2/decision_3)
//as seen below, i do not want them to output into the program, but into the document
//"Hardy_ChannelReport.txt"
}
ofstream output_file("Hardy_ChannelReport.txt");
if (output_file.is_open()) {
output_file << "First Last" << endl;
output_file << "Channel Classification Report" << endl;
output_file << "Channel 1 " << decision_1 << endl;
output_file << "Channel 2 " << decision_2 << endl;
output_file << "Channel 3 " << decision_3 << endl;
//In my current program all of these decisions remain undefined, i am not sure how to
//go about defining these yet so the proper output is put on to the file
}
}
|
Assignment:
GIVEN:
REFERENCE SIGNAL : 57 seconds long one dimensional data file . You have 57 data points. One data for each
second. This is the input data file .
THREE CHANNEL OUTPUT SIGNALS: 57 seconds long one dimensional data file. Consider this output under the
assumption that there is no delay in the channel. These are output data files form related channels
EXPECTED OUTPUT
• Confirmation message on the screen
• The output data file in the default folder. This output data file must have classification report for all three channels. One
output text file with three channel reports.
THE ROAD MAP
• Read the data from all four data files. And, place them into different 1-D arrays.
• Calculate the distance for each channel by utilizing the Euclidean Distance function you have developed
• Run the decision criteria to sort the channels. Use the user defined myDecision function here
• Write the final report in the output data file which was named as LastName_ChannelReport.txt
PSEUDOCODE FOR EUCLIDEAN DISTANCE CALCULATION
Distance (D) i = Reference Signal(RS) i – Measured signal at the Output of the Channel (MOC) i
Di = RS i – MOC I for example q21 – p21
Square of the distance SqD = D i
2 for example (q21-p21)
2
Do this calculation for all data points : Which is a loop to cover all 57 data point s.
Now you have 57 Square of the distances for that particular channel
Cumulative Distance(CD) = Sum of all 57 SqD = (SqD1 + SqD2 + SqD3 + ……. + SqD57)
Euclidean Distance ( ED) = square root of Cumulative Distance (CD) => ED = √𝐶𝐶𝐶𝐶
You are going to calculate 3 different Euclidean Distance (ED) by utilizing the myEDistance function . This means above
listed steps have to be done for all three channels.
ED_1 : Euclidean Distance between Reference signal and the signal at the output of the channel 1
ED_2 : Euclidean Distance between Reference signal and the signal at the output of the channel 2
ED_3 : Euclidean Distance between Reference signal and the signal at the output of the channel 3
DECISION CRITERIA (CHANNEL CLASSIFICATION).
Develop a function for channel classification. The input is the Euclidean Distance ( ED) and the output is the decision
about that particular channel. This function must be named as : myDecision
• If the Euclidean Distance ( ED) less than or equal to 0.5 then that channel can be used for communication.
This channel is going to labeled as BEST .
• If the ED is less than or equal to 1.0 and bigger than 0.5 then that channel can be seen as considerable
alternative if something happens to the best channel.
This channel is going to labeled as GOOD .
• If the ED less than or equal to 3.0 but bigger than 1.0 that channel will be considered as a worst case option.
This channel is going to labeled as LAST OPTION
• If the ED bigger than 3.0 then the that channel will be labeled as useless.
This channel is going to labeled as NOT GOOD ( do not use it)
Thank you for all of your help