Ask 1 Basee
Ask 1 Basee
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;
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;
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;