# How can I concatenate two vectors?

1 view (last 30 days)
mm99 on 18 Jan 2020
Commented: mm99 on 19 Jan 2020
Hi ! How can I 'join vector C and signal to get a matrix?
I've tried like this but I dont know if its okay.
f_sine=3e6; % sine frequency [Hz]
T1=1/f_sine; % sine period
n=5; % number of periods
tt=n*T1;
t1 = 0:dt:tt-dt;
burst=sin(2*pi*f_sine*t1);
ww1=hanning(length(burst)/2);
ww=[ww1;zeros(length(burst)/2,1)];
signal=burst.*ww';
iterations=30000;
C = zeros(1, iterations-numel(signal));
v = [signal, C]';
##### 2 CommentsShowHide 1 older comment
mm99 on 19 Jan 2020
corrected!

Turlough Hughes on 19 Jan 2020
Edited: Turlough Hughes on 19 Jan 2020
How can I 'join vector C and signal to get a matrix?
Depends on whether signal is a column vector or row vector
If it's a column vector you probably want to add a column of zeros to the right of signal:
v = [signal zeros( size(signal,1),1 )].' % note the matrix is transposed as you wrote in the original code
If its a row vector you could add zeros below singal as follows:
v = [signal; zeros( 1,size(signal,2) )].'
mm99 on 19 Jan 2020
thanks a lot!