Created
July 6, 2020 20:13
-
-
Save unalfaruk/4b97efc7cb5ce62f626ab919d51fd0e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% Sending binary data via sinusoidal signal manipulation | |
% Parameters | |
sig_len = 1000; % Signal length (in samples) | |
sampl_per_bin = 100; % Samples per binary representation | |
bin_data_len = sig_len/sampl_per_bin; %length of binary stream is a multiple of signal length | |
bin_data = round(rand(1,bin_data_len)); | |
sig_carrier_base = sin(2*pi*(0:(1/sampl_per_bin):(1-(1/sampl_per_bin)))); % Baseline carrier | |
sig_carrier_freq = sin(2*2*pi*(0:(1/sampl_per_bin):(1-(1/sampl_per_bin)))); % Double frequency | |
sig_carrier_phase = sin(2*pi*(0:(1/sampl_per_bin):(1-(1/sampl_per_bin)))+(pi/4)); % Phase shifted by 45 degrees | |
% Modulate sinusoidal carrier via amplitude, phase, and frequency | |
% manipulations | |
sig_bin = []; % Binary waveform | |
sig_ask = []; % Amplitude modulated | |
sig_psk = []; % Phase modulated | |
sig_fsk = []; % Frequency modulated | |
for ind = 1:1:bin_data_len | |
if (bin_data(ind)==1) | |
sig_bin = [sig_bin ones(1,sampl_per_bin)]; | |
sig_ask = [sig_ask sig_carrier_base]; | |
sig_psk = [sig_psk sig_carrier_base]; | |
sig_fsk = [sig_fsk sig_carrier_base]; | |
else | |
sig_bin = [sig_bin zeros(1,sampl_per_bin)]; | |
sig_ask = [sig_ask 0.5*sig_carrier_base]; | |
sig_psk = [sig_psk sig_carrier_phase]; | |
sig_fsk = [sig_fsk sig_carrier_freq]; | |
end | |
end | |
figure; | |
subplot(4,1,1); | |
plot(sig_bin); | |
title("Binary Signal"); | |
subplot(4,1,2); | |
plot(sig_ask); | |
title("ASK (Amplitude Shifting) Signal"); | |
subplot(4,1,3); | |
plot(sig_fsk); | |
title("FSK (Freq. Shifting) Signal"); | |
subplot(4,1,4); | |
plot(sig_psk); | |
title("PSK (Phase Shifting) Signal"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment