Repeat vector n times

279 次查看(过去 30 天)
numnum
numnum 2017-10-24
编辑: numnum 2017-10-24
I have a vector t_vec. I want to create another vector that is the repetition of t_vec n types, so that is shows somehting like this: [ion, ion, off, off, off, ion+randn, ion+randn, ioff, ioff, ioff,...], with a different value for randn each time
ton=2;
toff=3;
ion=0.7;
ioff=-6;
t_vec1(1:ton)=ion+randn;
t_vec1(ton+1:ton+toff)=ioff;
How do I do this?

采纳的回答

Honglei Chen
Honglei Chen 2017-10-24
编辑:Honglei Chen 2017-10-24
Have you tried repmat, say
n = 2;
t_vec = [ion ion ioff ioff ioff];
repmat(t_vec,1,n)
HTH

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by