Natural Sampling by Square Wave | Scigyan

Natural Sampling by Square Wave

Matlab program for Natural Sampling by Square Wave.

Matlab code

clc; close all; clear all;
fm=input('Enter the frequency of Message signal = ');
fc=input('Enter the frequency of Carrier signal = ');
A=input('Enter the amplitude of Message signal = ');
t = 0:0.0001:1/fm;

Sm=A*sin(2*pi*fm*t); % Message signal
Ssq=square(2*pi*fc*t); % Carrier signal (Square Wave)
% Conversion of Square Wave to Pulse train Sp
for i=1:length(Ssq)
    if(Ssq(i)<=0)
        Sp(i)=0;
    else
        Sp(i)=1;
    end
end
Sn=Sp.*Sm; % Natural Sampled Signal

subplot(4,1,1);
plot(t,Sm);
xlabel('Time-->');
ylabel('Amplitude-->');
title('Message Signal');

subplot(4,1,2);
plot(t,Ssq);
xlabel('Time-->');
ylabel('Amplitude-->');
title('Square wave');
axis([0 1/fm -A-1 A+1]);

subplot(4,1,3);
plot(t,Sp);
xlabel('Time-->');
ylabel('Amplitude-->');
title('Carrier Signal');
axis([0 1/fm -A-1 A+1]);

subplot(4,1,4);
plot(t,Sn);
xlabel('Time-->');
ylabel('Amplitude-->');
title('Natural Sampled Signal');

Command window

Enter the frequency of Message signal = 2
Enter the frequency of Carrier signal = 100
Enter the amplitude of Message signal = 1

Figure window

Natural-Sampling-by-Square-Wave
No comments:
Post a Comment

Related Posts Plugin for WordPress, Blogger...