Question about matricies in Matlab

1 visualización (últimos 30 días)
Sebastian Daneli
Sebastian Daneli el 14 de Nov. de 2021
Comentada: Sebastian Daneli el 14 de Nov. de 2021
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.

Respuesta aceptada

Paul
Paul el 14 de Nov. de 2021
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 comentario
Sebastian Daneli
Sebastian Daneli el 14 de Nov. de 2021
Thanks for the solution, it does the trick.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by