0% found this document useful (0 votes)
31 views12 pages

Signals and Systems Matlab

This document discusses analyzing signals and systems in a lab. It contains examples of plotting sinusoids, calculating statistics of signals, filtering signals through systems, and implementing a signal/no signal detector. The key aspects are analyzing sinusoids, filtering signals, and implementing a basic signal detector.

Uploaded by

Lekono Kago
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)
31 views12 pages

Signals and Systems Matlab

This document discusses analyzing signals and systems in a lab. It contains examples of plotting sinusoids, calculating statistics of signals, filtering signals through systems, and implementing a signal/no signal detector. The key aspects are analyzing sinusoids, filtering signals, and implementing a basic signal detector.

Uploaded by

Lekono Kago
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/ 12

Signals and Systems LAB

Question 1
a. n=1:50;
s=sin(2*pi*n/50);
stem(n,s)
xlabel('n')
ylabel('Amplitude')
title('Figure 1')

b.
>>n1=1;
>>n2=length(s);
i.
>>Maximum=max (s((n1:n2)-n(1)+1))
Maximum =

0.9980
ii.
>>Minimum=min (s((n1:n2)-n(1)+1))

Minimum=
-0.9980

iii.
>>Mean=mean (s((n1:n2)-n(1)+1))

Mean =

-3.2752e-17

iv.

>>Mean squared= mean(s((n1:n2)-n(1)+1).^2)

mean squared =

0.5000

v.

>>RMS=sqrt(mean(s((n1:n2)-n(1)+1).^2))
RMS =

0.7071

vi.

>>Energy=sum(s((n1:n2)-n(1)+1).^2)
Energy =

25

c.
T_s=1/100

T_s =

0.0100

t=1:T_s:50

plot(t,s)
xlabel('t')
ylabel('Amplitude')
title('Figure 2')
i.
Signalduration=length(s)

Signalduration=

4901

ii.

Energy=sum(s.^2)

Energy =

2.4500e+03

iii.

Mean=mean(s)

Mean =

-2.7769e-17
iv.

Avg Power=Energy./Signalduration
=0.50
v.
sqrt(mean(s.^2))

ans =

0.7070
Question 2.

a.

>> load('data_1.mat')

>> t=1:length(clarinet);

>> plot(t,clarinet)

>>xlim([0 500.00)]

>> xlabel('t')

>> ylabel('clarinet')

>> title('Figure 3')

b.

c.

i.

>> load('data_1.mat')

>> y=fft(clarinet);

>> plot(abs(y))
>> xlabel('freq')

>> ylabel('Amplitude')

Fundamental period for discrete-time signal= 232 samples

ii.

Fundamental period for continuous-time signal=0.00431 s

d.

>> hist(clarinet,50);

d.MSV=0.150

RMSV=0.387

e.

>> x=length(clarinet)

x=

22050
>> mean(clarinet((n1:n2)-n(1)+1))

ans =

-0.0029

>> energy=sum(clarinet((n1:n2)-n(1)+1).^2)

energy =

4.5256e+03

>>MS= mean((clarinet(n1:n2)-n(1)+1).^2)

MS =

0.2052

>> RMS=sqrt(mean((clarinet(n1:n2)-n(1)+1).^2))

RMS =

0.4530

3.

>> load('data_1.mat')

>> sys1_out = sys1_1(clarinet);

>> sys2_out = sys2_1(clarinet);

>> plot(sys1_out)

>> ylabel('Amplitude')

>> xlim([0 500.00])

>> title('Figure 5-signal of sys1')


>> load('data_1.mat')

>> sys1_out = sys1_1(clarinet);

>> sys2_out = sys2_1(clarinet);

>> plot(sys2_out)

>> ylabel('Amplitude')

>> xlabel('index t')

>> xlim([0 500.00])

>> title('Figure 6-signal of sys2')


3b. The frequency of the signal increased drastically. It also became more random as more lines that
had different amplitudes were created.

ii. The frequency appeared to have increased and became a bit orderly.

3c.

i. >> rmse=sqrt(mean((clarinet-sys1_out). ^2));

Rmse=0.198816185354747

>> rmse(2) =sqrt(mean((clarinet-sys2_out).^2));

Rmse=0.205288009879387

ii.sys1_out has the least error as the difference between the original signal(clarinet) and the modified
signal(sys1_out) is not as big as that of sys2_out.

4.

a. function [output, support_out] = sig_nosig1(mboc)


% function [output, support_out] = sig_nosig(input)
%
% SIG_NOSIG -- An implementation of the signal/no signal detector
% See Lab #1 Section 1.2.5 for details
%
% Input Parameters:
% input -- a signal to be labeled signal/no signal
%
% Output Parameters:
% output -- vector of 0/1 detection results for each block of the signal
% support_out -- a vector that contains the sample number that begins each block

% Written by Mark Bartsch, Winter 2002


% Modification History:
% 8/16/02 -- Added modification history (MB)
% 1/1/03 -- renamed "x_axis" to "support_out" to match lab manual (JF)

% Define a block size:


Block_size = 512;

% Define a threshold:
threshold = 0.2;

% Calculate the number of blocks:


Blockno= round(length(mboc)/Block_size);
output=[];
% Define your support_out:
support_out =1:Block_size:Blockno*Block_size;

for i=1:Blockno

n1=support_out(i);
n2=support_out(i)+Block_size-1;
block=mboc(n1:n2);
RMS=sqrt(mean(block.^2));
if RMS>threshold
output(end+1)=1;
else
output(end+1)=0;
end
end
end

% For each block of the signal:


% - Calculate the RMS value of the block
% - Compare the RMS value to a threshold
% - Store the result in an array called "output"

b.

[detection, i] = sig_nosig1(mboc)

>> stairs(i,detection,'k:');

hold on

plot(mboc)

xlabel("TIME")

ylabel("Amplitude")
c.Thrshold-0.01

You might also like