c++

In this assignment we will learn more about frequency response by writing a C++ function. Your function
should have the following prototype:
std::vector<double> calculate_mag_response(double start_freq, double end_freq,
int N, std::vector<double> num, std::vector<double> den)
The function should return a vector size N of magnitude responses in decibels of the transfer function
de ned by numerator and denominator vectors num and den.
I will test your function with a driver program call it say main.cpp, similar to the following. To adequately
test, you should drive this with more transfer functions.
#include <vector>
#include <iostream>
#include <cstdlib>
#include <ifstream>
using namespace std;
int main(int argc,char *argv[])
{
vector<double> myNum, myDen, results;
ifstream outfile;
int N;
outfile.open("datafile.txt");
myNum.push_back(1.0);
myNum.push_back(1.0); //create a smple zero at s=-1
myDen.push_back(1.0);
myDen.push_back(3.0);
myDen.push_back(2.0); //create two poles at s=-1,-2
results=calculate_mag_response(.1,1000,100,myNum,myDen); //Call the student function
if (N=results.size()!= 100)
{
cout << "Your function did not provide correct number of data points. Please fix" << endl;
exit(0);
}
for (int i=0;i<N;i++)
outfile << i << "\t" << results[i] << endl; //Write this garbage to a file
return(0);
}
That is your homework description. Where is your code and what is your question?

PS. Use code tags, please.
Topic archived. No new replies allowed.