Question about matricies in Matlab

1 次查看(过去 30 天)
Let's say that I have these three vectors:
x1=[9 6 9]';
x2=[0 2]';
x3=[3 1 2]'
Is it possitble to work with these in Matlab in something resembeling a matrix? Perhaps by turning the second vector into:
x2=[0 2 ~]
I don't want to add a zero to the second vector since that would add a datapoint that shouldn't exist.

采纳的回答

Paul
Paul 2021-11-14
You'll have to fill in the last spot ox x2 with something if you want to combine x1, x2, and x3 into a single matrix. The value you choose would depend on what the matrix will be used for. One option is to fill with not-a-number (NaN)
x1=[9 6 9]';
x2=[0 2]';
x3=[3 1 2]';
X = [x1 [x2;nan] x3]
X = 3×3
9 0 3 6 2 1 9 NaN 2

更多回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by