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

Write a function for the hanning window. For this function, you should take as i

ID: 3870846 • Letter: W

Question

Write a function for the hanning window. For this function, you should take as input parameters a part of the array (remember – whenever you pass in an array, no matter what you pass in, it is always interpreted as the address of the first value of the array. So if I passed in &arr[3], when that address enters the function, it will assume that the 4th address is the first address in the array. So DO NOT make a copy of each window and send that into the function – that is just wasteful and makes no sense). Assume the window size is an odd number in size, Weight the values appropriately. Return the weighted and averaged value. CODE in C++

Explanation / Answer

I have written code as i understood your requirement. if you want me to change please feel free to comment i will rewrite.

#include<iostream.h>
#include<math.h>
#include<conio.h>
#define PI 3.14
void hanning(int N,double *arrIn,double *window, double *alpha)
{
int i=0;
int n=N;//number of elements
for(i=0;i<n;i++)
{
alpha[i]= 0.5*(1-cos(2*PI*i/N)); //calcualting alpha w(i)=1/2(1-cos((2*PI*i)/N))
window[i]=alpha[i]*arrIn[i];
}
}
void main()
{
double arrIn[2000],window[2000],alpha[2000];
int i=0,n,ele;
clrscr();
cout<<" enter the number of elements:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<" Enter "<<i+1<<" Element:";
cin>>ele;
arrIn[i]=ele;
}
hanning(n,arrIn,window,alpha); //calling hanning funtion by passing array name
cout<<" input element Window alpha";
for(i=0;i<n;i++)
{
cout<<" "<<arrIn[i]<<" "<<window[i]<<" "<<alpha[i];
}
getch();
}

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