0% found this document useful (0 votes)
22 views2 pages

Untitled M

The document contains MATLAB code for simulating digital modulation techniques: Amplitude Shift Keying (ASK), Frequency Shift Keying (FSK), and Phase Shift Keying (PSK). It prompts the user to input the number of bits and generates binary signals, carrier signals, and modulated signals for each technique. The code also includes plotting functions to visualize the binary, carrier, and modulated signals in separate figures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Untitled M

The document contains MATLAB code for simulating digital modulation techniques: Amplitude Shift Keying (ASK), Frequency Shift Keying (FSK), and Phase Shift Keying (PSK). It prompts the user to input the number of bits and generates binary signals, carrier signals, and modulated signals for each technique. The code also includes plotting functions to visualize the binary, carrier, and modulated signals in separate figures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

%matlab code for digital modulation(ask, fsk and psk)

close all
clear all
clc

no_bit=input('Enter Number of Data Input on range 1-30 bits =') %no_bit only
valid for 1-30
no_bit_input= randint(1,no_bit); %no_bit_input == g
t_sample=10; %Hz %t_sample==f %contoh: f=2
f0=5; %f0 and f1 must be integers
f1=t_sample; %f0 and f1 must be integers

[bit,ask,carrier]=ASK(no_bit_input,t_sample); %ASK([1 0 1 1 0],2)


[bit,fsk,carrier]=FSK(no_bit_input,f0,f1); %FSK([1 0 1 1 0],1,2)
[bit,psk,carrier]=PSK(no_bit_input,t_sample); %PSK([1 0 1 1 0],2)

%% figure_________________--- ASK ---- ___________________


figure()
subplot(3,1,1);
plot(bit,'k','LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Binary Signal');
subplot(3,1,2)
plot(carrier, 'r', 'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Carrier Signal');
subplot(3,1,3);
plot(ask,'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('ASK modulation');

%% figure_________________--- FSK ---- ___________________


figure()
subplot(3,1,1);
plot(bit,'k','LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Binary Signal');
subplot(3,1,2)
plot(carrier, 'r', 'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Carrier Signal');
subplot(3,1,3);
plot(fsk,'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('FSK modulation');

%% figure_________________--- PSK ---- ___________________


figure()
subplot(3,1,1);
plot(bit,'k','LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Binary Signal');
subplot(3,1,2)
plot(carrier, 'r', 'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Carrier Signal');
subplot(3,1,3);
plot(psk,'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('PSK modulation');

%% figure_________________--- all ---- ___________________


figure()
subplot(5,1,1);
plot(bit,'m','LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Binary Signal');
subplot(5,1,2)
plot(carrier, 'r', 'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('Carrier Signal');
subplot(5,1,3);
plot(ask,'LineWidth',1.5);grid on;
%axis([0 100*length(no_bit_input) -2.0 2.0]);
title('ASK modulation');
subplot(5,1,4);
plot(fsk,'LineWidth',1.5);grid on;
title('FSK modulation');
%axis([0 100*length(no_bit_input) -2.0 2.0]);
subplot(5,1,5);
plot(psk,'LineWidth',1.5);grid on;
title('PSK modulation');
%axis([0 100*length(no_bit_input) -2.0 2.0]);

You might also like