test

3
Matlab Program for “Addition of two signals and Filtering the added signal through Window” Source Code clc; clear all; close all; % Decleration Section N=15; la=(N-1)/2; wc=3.57; fs=450; % Divison of Axses n=0:N-1; t=0:0.005:0.5; % Input Signals x1=sin(2*pi*10*t); x2=sin(2*pi*500*t); figure; subplot(2,1,1); plot(t,x1); xlabel('Time'); ylabel('Magnitude'); title('Signal 1 with Frequency = 10'); subplot(2,1,2); plot(t,x2); xlabel('Time'); ylabel('Magnitude'); title('Signal 2 with frequency = 500'); % Addition of Signals x=x1+x2; figure; plot(t,x); xlabel('Time axis'); ylabel('Magnitude of Added two Signals'); Title('Addition of Two Signals'); % Filtering Signal x_disc=sin((2*pi*10*n)/fs)+sin((2*pi*500*n)/fs); figure; plot(abs(fft(x,1024))); grid on; xlabel('fft points'); ylabel('magnitude'); title('Magnitude Spectrum'); % Use of FIR Filter h1=((sin(pi*(n-la)))-sin(wc*(n-la)))/(pi*(n-la)); h2=h1*(hamming(N)); y=filter(h2,1,x_disc); y1=fft(y,1024); figure; plot(abs(y1)); grid on; xlabel('fft points'); ylabel('Magnitude'); title('Magnitude Spectrum After Filtering');

Upload: mirishkar-s-ganesh

Post on 06-Dec-2015

212 views

Category:

Documents


0 download

DESCRIPTION

hg

TRANSCRIPT

Page 1: Test

Matlab Program for “Addition of two signals and Filtering the added signal

through Window”

Source Code

clc; clear all; close all;

% Decleration Section N=15; la=(N-1)/2; wc=3.57; fs=450;

% Divison of Axses n=0:N-1; t=0:0.005:0.5;

% Input Signals x1=sin(2*pi*10*t); x2=sin(2*pi*500*t); figure; subplot(2,1,1); plot(t,x1); xlabel('Time'); ylabel('Magnitude'); title('Signal 1 with Frequency = 10');

subplot(2,1,2); plot(t,x2); xlabel('Time'); ylabel('Magnitude'); title('Signal 2 with frequency = 500');

% Addition of Signals x=x1+x2; figure; plot(t,x); xlabel('Time axis'); ylabel('Magnitude of Added two Signals'); Title('Addition of Two Signals');

% Filtering Signal x_disc=sin((2*pi*10*n)/fs)+sin((2*pi*500*n)/fs); figure; plot(abs(fft(x,1024))); grid on; xlabel('fft points'); ylabel('magnitude'); title('Magnitude Spectrum');

% Use of FIR Filter h1=((sin(pi*(n-la)))-sin(wc*(n-la)))/(pi*(n-la)); h2=h1*(hamming(N)); y=filter(h2,1,x_disc); y1=fft(y,1024); figure; plot(abs(y1)); grid on; xlabel('fft points'); ylabel('Magnitude'); title('Magnitude Spectrum After Filtering');

Page 2: Test

Output

Page 3: Test