How can I concatenate unknown numbers of row vectors?

3 vues (au cours des 30 derniers jours)
ziad tarek
ziad tarek le 16 Déc 2020
if I have 3 (row vectors) for examble: A , B ,C
then I can do that
X=[A B C];
but, in my program : user will determine the number of (row vectors)
so in my case I want to do something like that:
X=[a(1),a(2),a(3),.....a(n)]
which a(1) .....a(n) is row vectors
how can I do that?
sorry for bad language.
if any one understand signals
this is code (but he does not work )
I want something like that
t1=linspace(-1,1,2000);
q{1}=4*cos(2*pi*t1/4);
t2=linspace(1,3,2000);
q{2}=3.*t2-5;
t3=linspace(3,5,2000);
q{3}=.5.*t3.^2-4;
t4=linspace(5,7,2000);
q{4}=4*exp(-0.5*t4);
t=linspace(-3,7,10000);
.
.
.
.
q{n}=4*exp(2*tn);
%I want (loop for example) to Generate something like the next line:
y=[q{1} q{2} q{3} q{4} .. .. q{n}]

Réponses (2)

Ameer Hamza
Ameer Hamza le 16 Déc 2020
You don't need a for-loop. For example
t1=linspace(-1,1,2000);
q{1}=4*cos(2*pi*t1/4);
t2=linspace(1,3,2000);
q{2}=3.*t2-5;
t3=linspace(3,5,2000);
q{3}=.5.*t3.^2-4;
t4=linspace(5,7,2000);
q{4}=4*exp(-0.5*t4);
q_all = [q{:}]; % [1x8000] vector

Walter Roberson
Walter Roberson le 16 Déc 2020

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by