Azzera filtri
Azzera filtri

How can I concatenate two vectors?

2 visualizzazioni (ultimi 30 giorni)
mm99
mm99 il 18 Gen 2020
Commentato: mm99 il 19 Gen 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.
Thanks in advance.
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 Commenti
Robert U
Robert U il 18 Gen 2020
Hi mm99,
your code snippet is not executable. "dt" and "N" are not given. As far as I see, "signal" is a vector whereas "vector" is a matrix. I guess, matrix dimensions and vector do not match, thus joining them is not possible. Provide executable code, and somebody will figure out how to match your variable sizes.
Kind regards,
Robert
mm99
mm99 il 19 Gen 2020
corrected!

Accedi per commentare.

Risposte (1)

Turlough Hughes
Turlough Hughes il 19 Gen 2020
Modificato: Turlough Hughes il 19 Gen 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) )].'
  3 Commenti
Turlough Hughes
Turlough Hughes il 19 Gen 2020
Ok, I see what you are asking.
v = zeros(1,iterations);
v(1:numel(signal))=signal;
mm99
mm99 il 19 Gen 2020
thanks a lot!

Accedi per commentare.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by