How can I concatenate unknown numbers of row vectors?
2 views (last 30 days)
Show older comments
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}]
0 Comments
Answers (2)
Ameer Hamza
on 16 Dec 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
0 Comments
Walter Roberson
on 16 Dec 2020
Do not put them into individual variables in the first place.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!