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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by