How can I concatenate unknown numbers of row vectors?

3 ビュー (過去 30 日間)
ziad tarek
ziad tarek 2020 年 12 月 16 日
回答済み: Walter Roberson 2020 年 12 月 16 日
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}]

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 16 日
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 2020 年 12 月 16 日

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by