Create a row vector with specific condition
2 ビュー (過去 30 日間)
古いコメントを表示
Hi I'd like to make a row vector as follows:
rowVect = [x y y y y y]
Right now, I'm doing:
rowVec = x
rowVec(2:5)=y
Is there a way to do this in one line of code?
Thanks C
0 件のコメント
採用された回答
James Tursa
2018 年 3 月 23 日
編集済み: James Tursa
2018 年 3 月 23 日
What's wrong with the first method you propose?
rowVect = [x y y y y y];
If you want to generalize it (maybe you don't know the number of y's you need ahead of time)
n = number of y's you want
rowVect = [x,repmat(y,1,n)];
That being said, your two-liner above is a pretty good way of doing it. Is there some particular reason you don't like it?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!