matlab - 使用matlab中其他向量的元素创建矩阵

标签 matlab vector matrix combinations

我有两个向量 a, b

a=[1; 2; 3; 4]
b=[1; 2; 3] 

我想创建一个看起来像这样的矩阵

c=[1 1; 2 1; 3 1; 4 1; 1 2; 2 2; 3 2; 4 2; 1 3; 2 3; 3 3; 4 3]

最佳答案

还有一种方法!

c = [repmat(a,numel(b),1),sort(repmat(b,numel(a),1))]

关于matlab - 使用matlab中其他向量的元素创建矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11240173/

相关文章:

c++ - 是否可能/建议将 vector 存储在结构中? C++

c++ - 现代 OpenGL : How to get the vector position of the cube?

R语言: Unexpected behaviour with function arguments in lapply

java.lang.ClassCastException : com. modelrenderer.MyVector3$1 无法转换为 com.modelrenderer.MyVector3

c++ - 模型观察矩阵 - C++、OpenGL

python - 与 numpy 的大型稀疏矩阵的余弦相似度

matlab - 神经网络激活函数

matlab - 使用 plotyy 设置 x 轴范围;数据消失

linux - 无法使用 jre 1.7.0_05 在 scientific linux 上启动 MATLAB guis (GUIDE)

java - Octave 的困难 "javaMethod"