Question about matricies in Matlab

조회 수: 1 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by