Generate a square pulse

8 次查看(过去 30 天)
Ahmed Hassanen
Ahmed Hassanen 2021-11-3
create exactly one square pulse with the specified parameters. This square pulse should be stored in the array called one_square. The dimensions of this array should be 1 x N_sq_pos. The length of the square pulse you generate should be equal to N_sq_pos, i.e., the variable one_square should not change dimensions after you generate the pulse. Keep in mind that you have to set the energy of the square pulse to be equal to E_bit.
Inputs:
% t_axis: Time axis
% T_sq_dur: Duration of the square pulse in seconds
% E_bit: Total energy in all samples of one square pulse
% fs: Sampling frequency
% x_bits: Sequence of input bits (if not available, then it is equal
% to 1)
% type: Type of bit coding, 'RZ' or 'NRZ' (default is 'RZ')
% Outputs:
% x_square: The sequence of samples corresponding to the pulse shaping
% of the input bits using a square pulse shape
Output like this :
  1 个评论
Ahmed Hassanen
Ahmed Hassanen 2021-11-3
编辑:Ahmed Hassanen 2021-11-3
Fixed Parameter:
fs = 1e5; % Sampling rate (samples per sec)
Ts = 1/fs; % Sampling time
N = 102400 - 1; % Total number of samples
t_axis = (0:N-1)*Ts; % Time axis (the same during the entire experiment)
f_axis = -fs/2:fs/N:fs/2-1/N; % Frequency axis (the same during the entire experiment)
T_sq = 100*Ts; % The duration of the square pulse (an integer number of sampling times)

请先登录,再进行评论。

回答(1 个)

Abhinaya Kennedy
Abhinaya Kennedy 2024-6-12
Generating the Pulse:
  1. Create a time axis "(t_axis)" from "0" to "T_sq_dur" with samples based on "fs".
  2. Calculate pulse amplitude (A) using "A = sqrt(E_bit / T_sq_dur)".
  3. Generate a binary sequence "(x_square)" with "x_bits" for the pulse duration (considering RZ transitions if applicable).
  4. Scale the sequence by A to get the final pulse with the required energy level.\
Array Dimensions:
The pulse ("one_square") should be a 1 x N_sq_pos array, where N_sq_pos is the number of samples based on "fs". This ensures the array maintains its size after generation.
By following these steps, you can create a square pulse and store it in the "one_square" array for further use.

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by