Filter löschen
Filter löschen

Assign one name to three variables in table

1 Ansicht (letzte 30 Tage)
Ali Tawfik
Ali Tawfik am 5 Mai 2020
Bearbeitet: Cris LaPierre am 5 Mai 2020
clear all;
yy = table(ii,y,t)
I would like the yy table to be only one name for each [high;M;LOW].
So, I would like to have the name 0 for the three elements in u. Is that possible?? Can anyone help?
  1 Kommentar
Image Analyst
Image Analyst am 5 Mai 2020
Bearbeitet: Image Analyst am 5 Mai 2020
I don't understand. There is only one name (High, M, or LOW) for each row:
yy =
6×3 table
ii y t
__ ________ __
0 {'High'} 33
0 {'M' } 69
0 {'LOW' } 12
45 {'High'} 13
45 {'M' } 14
45 {'LOW' } 15
so what's the problem? The "three variables in table" in the table are ii, y, and t -- these are often also called fieldnames or columns - just depends on how people call them.
And what is "the name 0"? Do you mean the values of 0 in rows 1 through 3? Again, each row has only one cell with one word in it for the "y" field of the table.
What do you want your table to look like? Do you want only 2 rows in the table, with values in the "ii" field of 0 and 45? If so, what value would the y column take on? I have no idea so please spell out what you want your table to look like.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 5 Mai 2020
Bearbeitet: Cris LaPierre am 5 Mai 2020
It sounds like you want table variable y to be a categorical. If you don't want duplicates, you can set those rows equal to missing.
If I understand what you are asking, I might do the following
yy = table('Size',[6 3],'VariableTypes',["double","categorical","double"]);
yy.Properties.VariableNames = ["ii","y","t"];
yy.ii = ii;
yy.t = t
ii y t
__ ___________ __
0 High 33
0 M 69
0 LOW 12
45 <undefined> 13
45 <undefined> 14
45 <undefined> 15


Mehr zu Tables finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by