Joke
-
Upload
manish-123 -
Category
Documents
-
view
10 -
download
0
description
Transcript of Joke
code
Experiment 1: Write a program to implement convolution of x(n) with h(n)using linear convolution and verify the result y(n) as below.x(n) = [1,1,1,1,0.5,0.5,0.5,0.5 ] , h(n) = [0.3,0.25,0.2,0.15,0.1,0.05] andy(n) == [0.3, 0.55,0.75,0.9,0.85,0.775,0.675,0.6,0.4.0.25,0.15,0.075,0.025]#include<math.h>#include<rt_fp.h>float x[13]={1,1,1,1,0.5,0.5,0.5,0.5};float h[13]={0.3,0.25,0.2,0.15,0.1,0.05};float y[13]={0};void main(){int n,k;for(n=0;n<13;n++){for(k=0;k<=n;k++){y[n]=y[n]+x[k]*h[n-k];}}}void SystemInit(){}Output
Experiment 2: Write a program for circular convolution of the following inputsx(n) and h(n) and Verify the output y(n) as given below.x(n) = [1,1,1,2,1,1] , h(n) = [1,1,2,1] and y(n) = [6,5,5,6,6,7]Program#include<math.h>#include <rt_fp.h> float x[6]={1,1,1,2,1,1}; float h[6]={1,1,2,1}; float y[6]={0};int main(){int n,k,i;for(n=0;n<=5;n++){
for(k=0;k<=5;k++){if(n-k>=0){
y[n] = __aeabi_fadd (y[n],__aeabi_fmul (x[k],h[n-k]));}else{i=6+(n-k);y[n] = __aeabi_fadd (y[n],__aeabi_fmul (x[k],h[i]));}
}}
return 0;}void SystemInit()
{}Output Experiment 3: Implement an 8-point DFT for the inputs x(n) and verify theresult as X(K). Where,x(n) = [1,1,1,1,1,1,0,0] and X(K) = [ 6,-0.707-j1.707,1-j,0.707+j0.293,0,0.707-j0.293,1+j,-0.707+j1.707]program#include<math.h>#include<rt_fp.h> int x[8]={1,1,1,1,1,1,0,0};float X[8];double real[8];double imag[8];double a,b;int N=8;#define pi 3.145842main(){
int i,n,j,k;for(k=0;k<8;k++)
{ for(n=0;n<N;n++) {
a=cos((2*pi*n*k)/N); b=sin((2*pi*n*k)/N);
real[k]=__aeabi_dadd(real[k],__aeabi_dmul(x[n],a));
imag[k]=__aeabi_dadd(imag[k],__aeabi_dmul(x[n],-b));
} }
return 0; }
void SystemInit(){}Output Experiment 4: Find IDFT of the sequence X(K) = [ 11110000].Verify that x (n) = [0.5,0.125+j0.30175, 0,0.125+j0.05175, 0,0.125-j0.05175,0,0.125-j0.30175] program#include<math.h>#include<rt_fp.h>int X[8]={1,1,1,1,0,0,0,0};double real[8];double imag[8];double a,b;int N=8;#define pi 3.14main(){
int n,k;for(n=0;n<N;n++) {
for(k=0;k<N;k++) {