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

C++ help method to measure the effect of the channel, we need a To implement a c

ID: 3915438 • Letter: C

Question

C++ help

method to measure the effect of the channel, we need a To implement a channel i comparison technique. What is the best way to compare two signals? The answer for this critical question is found in mathematics: Euclidean Distance. In digital voice communication, channel identification is been done by applying the Euclidean distance technique. EUCLIDEAN DISTANCE In mathematics, the Euclidean distance or Euclidean metric, is the "ordinary" distance between two points that one would measure with a ruler, and given by the Pythagorean formula. In one-dimensional signal processing, the distance between two points on the real line is the absolute value of their numerical difference. Thus, if x and y are two points on the real line, then the distance between them is given by: Distan Time If we measure the distance between two data series rather than two points, the Euclidean distance formula becomes i-1 where q1,q2,q3,.,qN represent reference signal data p1,p2,p3,..pN represent channel data If there were no distortion in a given channel, that channel output file would be exactly the same as the reference signal. In that case, Euclidean distance would be zero (q1-p1, q2-p2,.. qN pN) Your task is to develop a C++ program that will do this: o Request information from the user o Open data files and write data to 1-D arrays. o Calculate Euclidean distance for each channel, compared to the reference channel. o Determine channel classification based on the given decision criteria. o Report on the quality of the communication channel(s) in a single file.

Explanation / Answer

#include<iostream>

#include<fstream>

#include<cmath>

using namespace std;

int main()

{

//declare file names

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");

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

}

}

Edit & Run

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)

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