0% found this document useful (0 votes)
21 views23 pages

Logeshdspmanual

Good

Uploaded by

kaviyakavi638261
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views23 pages

Logeshdspmanual

Good

Uploaded by

kaviyakavi638261
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

EX NO : Room Acoustics and Convolution

DATE :

AIM :
To write and simulate a MATLAB program to compute the how to do the effect of a
room’s impulse response on an audio signal to demonstrate convolution.

SYSTEM SPECIFICATION:

System with MATLAB 17.0.


Processor: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz 2.94 GHz
System type:32-bit Operating System
ALGORITHM:

1. Create a new M file.

2. Save the file as filename.m

3. The signal is room’s impulse response on an audio signal to demonstrate convolution.

THEORY :
Convolution is a mathematical operation used to determine the output of a linear
time-invariant (LTI) system when an input signal is applied. A real-life example is modeling
how a room’s acoustics (impulse response) affect a transmitted sound signal.
PROGRAM :
% MATLAB Example: Convolution to Model Room Acoustics
Clc;
Clear;
Close all;
Fs = 1000;
T = 0:1/fs:1;
Input_signal = sin(2*pi*5*t);
Room_impulse_response = [1, 0.5, 0.50, 0.100];
Output_signal = conv(input_signal, room_impulse_response, ‘same’);
T_out = linspace(0, length(output_signal)/fs, length(output_signal));
Figure;
Subplot(3,1,1);
Plot(t, input_signal, ‘b’, ‘LineWidth’, 1.5);
Title(‘Input Signal’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Grid on;
Subplot(3,1,2);
Stem(0:length(room_impulse_response)-1, room_impulse_response, ‘r’, ‘LineWidth’,
1.5);
Title(‘Impulse Response of the Room’);
Xlabel(‘Samples’);
Ylabel(‘Amplitude’);
Grid on;
Subplot(3,1,3);
Plot(t_out, output_signal, ‘k’, ‘LineWidth’, 1.5);
Title(‘Output Signal (After Convolution)’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Grid on;
Disp(‘Convolution complete: Room acoustics applied to the input signal.’);

Output :
RESULT :
EX NO : FIR Filter for Noise Reduction
DATE :

AIM :
To write and simulate a MATLAB program to compute FIR filter to remove high-
frequency noise from a noisy sinusoidal signal.

SYSTEM SPECIFICATION:

System with MATLAB 17.0.


Processor: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz 2.94 GHz
System type: 32-bit Operating System
ALGORITHM:

1.Create a new M file.

2.Save the file as filename.m

3. noisy signal with added high-frequency noise.


PROGRAM :

% MATLAB Example: ECG Signal Processing with Low-Pass FIR Filter


Clc;
Clear;
Close all;
Fs = 360;
T = 0:1/fs:5;
Ecg_signal = 1.5 * sin(2*pi*1*t) + 0.5 * sin(2*pi*0.5*t);
Noise = 0.2 * randn(size(t));
Noisy_ecg = ecg_signal + noise;
Filter_order = 50;
Cutoff_freq = 40;
Normalized_cutoff = cutoff_freq / (fs/2);
Fir_coeffs = fir1(filter_order, normalized_cutoff);
Filtered_ecg = filter(fir_coeffs, 1, noisy_ecg);
Figure;
Subplot(3,1,1);
Plot(t, ecg_signal, ‘g’, ‘LineWidth’, 1.5);
Title(‘Original Clean ECG Signal’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Grid on;
Subplot(3,1,2);
Plot(t, noisy_ecg, ‘r’, ‘LineWidth’, 1.5);
Title(‘Noisy ECG Signal’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Grid on;
Subplot(3,1,3);
Plot(t, filtered_ecg, ‘b’, ‘LineWidth’, 1.5);
Title(‘Filtered ECG Signal (After Low-Pass FIR Filter)’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Grid on;
Disp(‘FIR Filter Coefficients:’);
Disp(fir_coeffs);

OUTPUT:
FIR Filter Coefficients:
Columns 1 through 7
-0.0010 -0.0010 -0.0004 0.0006 0.0018 0.0026 0.0022
Columns 8 through 14
-0.0000 -0.0035 -0.0068 -0.0073 -0.0035 0.0043 0.0131
Columns 15 through 21
0.0179 0.0140 -0.0000 -0.0201 -0.0374 -0.0403 -0.0199
Columns 22 through 28
0.0257 0.0890 0.1547 0.2041 0.2225 0.2041 0.1547
Columns 29 through 35
0.0890 0.0257 -0.0199 -0.0403 -0.0374 -0.0201 -0.0000
Columns 36 through 42
0.0140 0.0179 0.0131 0.0043 -0.0035 -0.0073 -0.0068
Columns 43 through 49
-0.0035 -0.0000 0.0022 0.0026 0.0018 0.0006 -0.0004
Columns 50 through 51
-0.0010 -0.0010
RESULT :
EX NO :
Analysis of Clean and Noisy Signal
DATE :

AIM :
To write and simulate a MATLAB program to compute the Spectral Analysis of
Clean and Noisy Signals.

SYSTEM SPECIFICATION:

System with MATLAB 17.0.


Processor: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz 2.94 GHz
System type:32-bit Operating System

ALGORITHM:

1. Create a new M file.

2. Save the file as filename.m

3. Generate the Spectral Analysis of Clean and Noisy Signals.

4. Plot the graph.

PROGRAM :
Clc;
Clear;
Close all;
Fs = 1000;
T = 0:1/fs:1-1/fs;
F_signal = 50;
% Generate the clean signal (sine wave)
Clean_signal = sin(2*pi*f_signal*t);
Noise = 0.5 * randn(size(t));
Noisy_signal = clean_signal + noise;
% Perform FFT on both signals
N = length(clean_signal);
Freq = fs * (0N/2)) / N;
% FFT of the clean signal
Clean_signal_fft = fft(clean_signal);
Clean_signal_magnitude = abs(clean_signal_fft / N);
Clean_signal_magnitude = clean_signal_magnitude(1:N/2+1);
% FFT of the noisy signal
Noisy_signal_fft = fft(noisy_signal);
Noisy_signal_magnitude = abs(noisy_signal_fft / N);
Noisy_signal_magnitude = noisy_signal_magnitude(1:N/2+1);
% Plot the time-domain signals
Figure;
Subplot(2,1,1);
Plot(t, clean_signal, ‘b’, ‘LineWidth’, 1.5);
Hold on;
Plot(t, noisy_signal, ‘r’, ‘LineWidth’, 1.2);
Title(‘Time-Domain Signals’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Legend(‘Clean Signal’, ‘Noisy Signal’);
Grid on;
% Plot the frequency-domain spectra
Subplot(2,1,2);
Plot(freq, clean_signal_magnitude, ‘b’, ‘LineWidth’, 1.5);
Hold on;
Plot(freq, noisy_signal_magnitude, ‘r’, ‘LineWidth’, 1.2);
Title(‘Frequency-Domain Spectral Analysis’);
Xlabel(‘Frequency (Hz)’);
Ylabel(‘Magnitude’);
Legend(‘Clean Signal Spectrum’, ‘Noisy Signal Spectrum’);
Grid on;
% Display dominant frequencies
[~, clean_peak_idx] = max(clean_signal_magnitude);
[~, noisy_peak_idx] = max(noisy_signal_magnitude);
Fprintf(‘Dominant frequency of clean signal: %.2f Hz\n’, freq(clean_peak_idx));
Fprintf(‘Dominant frequency of noisy signal: %.2f Hz\n’, freq(noisy_peak_idx));
OUTPUT :

Dominant frequency of clean signal: 50.00 Hz


Dominant frequency of noisy signal: 50.00 Hz
RESULT :
EX NO : Filtering High-Frequency Noise from Sensor Data Using DFT

DATE :

AIM :
To write and simulate a MATLAB program to compute the Filtering High-
Frequency Noise from Sensor Data Using DFT

SYSTEM SPECIFICATION:

System with MATLAB 17.0.


Processor: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz 2.94 GHz
System type: 32-bit Operating System

ALGORITHM:

1. Create a new M file.

2. Save the file as filename.m

3. Generate the Filtering High-Frequency Noise from Sensor Data Using DFT

4. Plot the graph.

PROGRAM :
% Define the sampling parameters
Fs = 1000;
T = 1;
T = 0:1/fs:T-1/fs;
F_signal = 10;
Sensor_signal = sin(2*pi*f_signal*t);
F_noise = 150;
Noise = 0.5 * sin(2*pi*f_noise*t);
Noisy_signal = sensor_signal + noise;
Noisy_signal_fft = fft(noisy_signal);
N = length(t);
F = (0:n-1)*(fs/n);
% Low-pass filter: Remove frequencies above 50 Hz
Cutoff_freq = 50;
Filter = (f <= cutoff_freq);
% Apply the filter to the DFT of the noisy signal
Filtered_fft = noisy_signal_fft .* filter;
Filtered_signal = real(ifft(filtered_fft));
Figure;
% Plot the original noisy signal
Subplot(2,2,1);
Plot(t, noisy_signal);
Title(‘Noisy Sensor Signal (10 Hz + Noise)’);
Xlabel(‘Time (seconds)’);
Ylabel(‘Amplitude’);
% Plot DFT of the noisy signal (Before filtering)
Subplot(2,2,2);
Plot(f(1:floor(n/2)), abs(noisy_signal_fft(1:floor(n/2))));
Title(‘DFT of Noisy Sensor Signal (Before Filtering)’);
Xlabel(‘Frequency (Hz)’);
Ylabel(‘Magnitude’);
Xlim([0 200]);
% Plot the filtered signal (after applying low-pass filter)
Subplot(2,2,3);
Plot(t, filtered_signal);
Title(‘Filtered Sensor Signal (Low-pass Filtered)’);
Xlabel(‘Time (seconds)’);
Ylabel(‘Amplitude’);
% Plot DFT of the filtered signal (After filtering)
Subplot(2,2,4);
Plot(f(1:floor(n/2)), abs(filtered_fft(1:floor(n/2))));
Title(‘DFT of Filtered Sensor Signal (After Filtering)’);
Xlabel(‘Frequency (Hz)’);
Ylabel(‘Magnitude’);
Xlim([0 200]);

OUTPUT :
RESULT :
EX NO : Echo Detection in an Audio Signal in correlation

DATE :

AIM :
To write and simulate a MATLAB program to compute the Echo Detection in an
Audio Signal in correlation.

SYSTEM SPECIFICATION:

System with MATLAB 17.0.


Processor: Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz 2.94 GHz
System type: 32-bit Operating System

ALGORITHM:

1. Create a new M file.

2. Save the file as filename.m

3. Generate the Align the Signals Usinf Cross- Correlation of a given sequence
using command.

4. Plot the graph.

PROGRAM :
% Example: Echo detection using correlation
Fs = 1000;
T = 0:1/fs:1;
F = 5;
Original_signal = sin(2 * pi * f * t);
Delay = 0.2;
Delay_samples = round(delay * fs);
Echo_signal = [zeros(1, delay_samples), original_signal];
Echo_signal = echo_signal(1:length(original_signal));
Noisy_signal = echo_signal + 0.1 * randn(size(echo_signal));
[corr_values, lag] = xcorr(noisy_signal, original_signal);
[~, max_index] = max(corr_values);
Detected_delay = lag(max_index) / fs;
Figure;
Subplot(3, 1, 1);
Plot(t, original_signal);
Title(‘Original Signal’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Subplot(3, 1, 2);
Plot(t, noisy_signal);
Title(‘Noisy Echo Signal’);
Xlabel(‘Time (s)’);
Ylabel(‘Amplitude’);
Subplot(3, 1, 3);
Plot(lag / fs, corr_values);
Title(‘Cross-Correlation’);
Xlabel(‘Lag (s)’);
Ylabel(‘Correlation’);
Grid on;
Fprintf(‘Detected delay: %.2f seconds\n’, detected_delay);
OUTPUT :
Correlation
Detected delay: 0.00 seconds
RESULT :

You might also like