Replacing element in table

4 vues (au cours des 30 derniers jours)
Sebastian Daneli
Sebastian Daneli le 15 Nov 2021
I have this table
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=[3 1; 8 9];
X=table(X1,X2,X3)
X = 2×3 table
X1 X2 X3 ___________ ______ ______ 9 6 9 0 2 3 1 3 2 7 4 0 8 9
How do I replace X3 with X1 so that i get
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=X1;
X=table(X1,X2,X3)
X = 2×3 table
X1 X2 X3 ___________ ______ ___________ 9 6 9 0 2 9 6 9 3 2 7 4 0 3 2 7
Without having to make an new table that is.

Réponse acceptée

Dave B
Dave B le 15 Nov 2021
Modifié(e) : Dave B le 15 Nov 2021
You can do point to table variables with the syntax tablename.variablename:
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=[3 1; 8 9];
X=table(X1,X2,X3)
X = 2×3 table
X1 X2 X3 ___________ ______ ______ 9 6 9 0 2 3 1 3 2 7 4 0 8 9
X.X3=X1 % or X.X3=X.X1 in this case
X = 2×3 table
X1 X2 X3 ___________ ______ ___________ 9 6 9 0 2 9 6 9 3 2 7 4 0 3 2 7
  1 commentaire
Sebastian Daneli
Sebastian Daneli le 15 Nov 2021
That was effective. Than you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables 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