Question about matricies in Matlab

2 ビュー (過去 30 日間)
Sebastian Daneli
Sebastian Daneli 2021 年 11 月 14 日
コメント済み: Sebastian Daneli 2021 年 11 月 14 日
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
  1 件のコメント
Sebastian Daneli
Sebastian Daneli 2021 年 11 月 14 日
Thanks for the solution, it does the trick.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by