Acquisition of One and Two Dimensional Signals

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Date:05/09/2022 Experiment No: 01

ACQUISITION OF ONE AND TWO DIMENSIONAL SIGNALS

AIM: To write a Mat lab code for the acquisition of one and two-dimensional signals

Case 1:
Generation of sinusoidal signal

Algorithm:
1. Assign suitable sampling frequency and end time (stop time ) of signal
2. Generate the continuous sinusoidal signal
3. Plot the one-dimensional sinusoidal signal
4. Label the x-axis as “ Time in seconds” using xlabel command
5. Label the y-axis as “ Amplitude in volts” using ylabel command
Program:

% case1:Generation of sine waveform(1D signal)

clc;
clear all;
fs=4000;
dt=1/fs;
stoptime=0.5;
t=(0:dt:stoptime-dt);
F=50;
y1=sin(2*pi*F*t);
plot(t,y1);
xlabel('time in seconds');
ylabel('amplitude in volts');
title('sine wave generation');
Output:
Case 2:
Generation of discrete signal
Algorithm:
1. Assign suitable length of discrete signal
2. Generate the discrete sinusoidal signal
3. Plot the one-dimensional discrete sinusoidal signal 4.
Label the x-axis as time index using xlabel command 5.
label the y-axis as x(n) using ylabel command
Program:

%Generation of discrete waveform

N=64;
n=0:N-1;
w=2*pi/N;
X1=sin(n*w);
stem(X1);
xlabel('time index,n\right arrow');
ylabel('x(n)\right arrow');
title('input signal,one cycle');
Output:
Case 3:
Live recording of speech signal using headset (audiorecorder function)

Algorithm:
1. Assign suitable sampling frequency, number of channel, and bits
2. Record the live speech using audiorecorder function 3. Record for
the number of seconds specified by length 4. Play and plot the
recorded speech signal
5. Assign x-label as “ Time “ and y-label as “ Amplitude “
Program:

%Live recording of speech

Fs=8000;
nBits=8;
nchannel=1;
recobj = audiorecorder(Fs,nBits,nchannel);
disp('start speaking')
recordblocking(recobj,5);
disp('end of recording');
play(recobj);
myrecording=getaudiodata(recobj);
plot(myrecording);
xlabel('time');
ylabel('amplitude');
title('speech signal');
Output:
Case 4:
To acquire stored audio data in .WAV format using audioread function

Algorithm:
1. Assign the sample Fs
2. Read the recorded one-dimensional speech signal using audio read function
3. Use sound function to send audio signal y to the speaker at sample rate Fs 4.
Plot the speech signal
5. Assign x-label as “ Seconds “ and y-label as “ Amplitude”
Program:

%Recorded signal

Fs=44100;
[y,fs]=audioread(‘C:\Users\Public\Music\Sample Music\Sleep
Away.mp3 ‘); dt=1/fs;
t=0:dt:(length(y)*dt)-dt;
sound(y,fs);
plot(t,y);
xlabel('seconds');
ylabel('amplitude');
figure;
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
Output:
Case 5:
Acquisition of two-dimensional signal (image)
Algorithm:
1. Acquire 2D signal (image) using imread function
2. Plot the image
3. Apply DCT for the image
4. Using imshow command plot the result
5. Apply IDCT, recover the original image
Program:

%Acqusition of 2D signal

clc;
clear all;
a=imread('cameraman.tif');
[M N]=size(a);
figure;
subplot(3,1,1);
imshow(a);
b=dct2(a);
subplot(3,1,2);
imshow(abs(b),[]);
subplot(3,1,3);
e=idct2(b);
subplot(3,1,3);imshow(e,[]);
Output:
Prelab(10)

Demo(20)

Manual(10)

VivaVoce(10)

Total(50)

Result:
Matlab code for acquisition of one and two dimensional signal had been written and
executed

You might also like