0% found this document useful (0 votes)
2 views1 page

Ask 1 Basee

The document describes a MATLAB function for basic Amplitude Shift Keying (ASK) modulation, which modulates a binary data stream onto a carrier signal by varying the amplitude based on the binary values. It includes error checking for the input binary data and calculates the ASK signal over a specified time vector. An example usage is provided to demonstrate how to visualize the binary data stream and the resulting ASK modulated signal.

Uploaded by

copeyic220
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Ask 1 Basee

The document describes a MATLAB function for basic Amplitude Shift Keying (ASK) modulation, which modulates a binary data stream onto a carrier signal by varying the amplitude based on the binary values. It includes error checking for the input binary data and calculates the ASK signal over a specified time vector. An example usage is provided to demonstrate how to visualize the binary data stream and the resulting ASK modulated signal.

Uploaded by

copeyic220
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

function ask_signal = basic_ask_modulator(binary_data, bit_rate, carrier_frequency, amplitude_on, amplitude_off,

time_vector) % basic_ask_modulator(binary_data, bit_rate, carrier_frequency, amplitude_on, amplitude_off, time_vector)


% implements basic Amplitude Shift Keying (ASK) modulation. % % What it does: This function modulates a binary data
stream onto a carrier % signal using Amplitude Shift Keying (ASK). In ASK, the amplitude of the % carrier signal is
varied according to the value of the digital data. % Typically, one amplitude level represents a binary '1', and another %
amplitude level (often zero) represents a binary '0'. % % Theory: Amplitude Shift Keying (ASK) is a form of amplitude
modulation % that represents digital data as variations in the amplitude of a carrier % wave. For binary ASK, two
distinct amplitudes are used. A common form is % On-Off Keying (OOK), where one amplitude is non-zero (for '1') and
the % other is zero (for '0'). This function allows for two arbitrary amplitude % levels for '1' and '0'. The duration of each
amplitude level corresponds % to the bit duration, which is the inverse of the bit rate.

if ~isvector(binary_data) || ~all(ismember(binary_data, [0, 1]))


error('Binary data must be a vector of 0s and 1s.');
end

bit_duration = 1 / bit_rate;
ask_signal = zeros(size(time_vector));

for i = 1:length(binary_data)
start_time = (i - 1) * bit_duration;
end_time = i * bit_duration;

carrier = cos(2 * pi * carrier_frequency * time_vector);

if binary_data(i) == 1
ask_signal = ask_signal + (time_vector >= start_time & time_vector < end_time) .* (amplitude_on * carrier);
else
ask_signal = ask_signal + (time_vector >= start_time & time_vector < end_time) .* (amplitude_off * carrier);
end
end

end

% Example usage: data = [1 0 1 1 0 0 1]; rate = 5; % 5 bits per second fc = 40; % Carrier frequency of 40 Hz amp_on =
5; amp_off = 0; t = 0:0.001:2;

ask_modulated = basic_ask_modulator(data, rate, fc, amp_on, amp_off, t);

figure; subplot(2, 1, 1); stairs(0:1/rate:(length(data)-1)/rate, [data, data(end)]); xlabel('Time (s)'); ylabel('Binary Data');
title('Binary Data Stream'); grid on;

subplot(2, 1, 2); plot(t, ask_modulated); xlabel('Time (s)'); ylabel('ASK Modulated Signal'); title('Amplitude Shift Keying
(ASK) Modulation'); grid on;

You might also like