How to augment a vector into another vector?

3 次查看(过去 30 天)
v1 = [0 1 2 3],
v2 = [0 1 2]
the resultant
v3 =[0 0;
1 0;
2 0;
3 0;
0 1;
1 1;
2 1;
3 1;
0 2;
1 2;
2 2;
3 2]

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2015-4-14
v1 = [0 1 2 3],
v2 = [0 1 2]
[a,b]=ndgrid(v1,v2)
out=[a(:) b(:)]

更多回答(1 个)

tdd4c1
tdd4c1 2015-4-14
v3 = [repmat(v1',3,1) reshape(repmat(v2,4,1),1,[])']

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by