Question about matricies in Matlab

1 vue (au cours des 30 derniers jours)
Sebastian Daneli
Sebastian Daneli le 14 Nov 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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by