Clear Filters
Clear Filters

How to add two rows end to end to make a longer row?

3 views (last 30 days)
I am trying to create a signal where
00 state is represented by 4 sine waves, I want to create 00 01 10 11 signal train which sine wave has 2 ghz so a perios is 5 ns and total lengh is going to be 100 ns with 4 period of no signal at the end of 00 01 10 11.
01 is represented with no signal for a single period and 3 sine waves
10 is represented 2 period of no signal and 2 sines after
11 is 3 period of no signal and 1 sine after
so what I come up with adding sine wave and 0 matrices end to end to create 00 01 10 11 signal
The code I wrote to check if it is working is only for two bits at the start 00 and 01.
f=2e9; %frequency [Hz]
t=(0:1/(f*100):4e-9); %total time
t1=(0:1/(f*100):2e-9); %first continious sine wave
tgap1=(2e-9:1/(f*100):2.5e-9); %first period of 0 at the start of 01
t2=(2.5e-9:1/(f*100):4e-9); %rest of the 01 bit
a=1; %amplitude [V]
phi=0; %phase
wf1=a*sin(2*pi*f*t1+phi);
wf2=0*sin(2*pi*f*tgap1+phi);
wf3=a*sin(2*pi*f*t2+phi);
From here I don"t know how to add wf1 wf2 and wf3 end to end to create 1x801 double array that maches length of time array t which is 1x801 double.

Accepted Answer

Nipun
Nipun on 12 Jun 2024
Hi Isa,
I understand that you want to create a signal train for the states 00, 01, 10, and 11 with specific sine wave and no-signal periods. Here is a MATLAB code snippet that achieves this:
f = 2e9; % Frequency [Hz]
T = 1 / f; % Period [s]
t_total = 100e-9; % Total length [s]
fs = f * 100; % Sampling frequency
t = 0:1/fs:t_total-1/fs; % Time vector
% Define segments
t_segment = 0:1/fs:5*T-1/fs; % Segment length of 5 periods
sine_wave = sin(2*pi*f*t_segment); % Sine wave for 4 periods
% Define state signals
wf_00 = [sine_wave sine_wave sine_wave sine_wave];
wf_01 = [zeros(1, fs*5*T) sine_wave sine_wave sine_wave];
wf_10 = [zeros(1, 2*fs*5*T) sine_wave sine_wave];
wf_11 = [zeros(1, 3*fs*5*T) sine_wave];
% Concatenate state signals
signal = [wf_00 wf_01 wf_10 wf_11 zeros(1, 4*fs*5*T)];
% Plot the signal
plot(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('00 01 10 11 Signal Train');
For more details on sine waves and signal processing in MATLAB, refer to:
Hope this helps.
Regards,
Nipun

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!