I have a question:
I have this table:
Lemon Banana Apple
Andy 1 5 8
Roman 6 7 10
Nico 15 22 30
the Variables are 'name' and 'fruit'. When i define name=Andy and fruit=banana, the variable x should be 5. How i can program this and how should i build the table?

 Akzeptierte Antwort

Niwin Anto
Niwin Anto am 22 Feb. 2018
Bearbeitet: Niwin Anto am 22 Feb. 2018

1 Stimme

Use the code snippet shown below.
T = table([1;6;15],[5;7;22],[8;10;30],'VariableNames',{'Lemon','Banana','Apple'},...
'RowNames',{'Andy','Roman','Nico'});
name = 'Andy';
fruit = 'Banana';
x = T{name,fruit}
For more about table creation and indexing, refer these links. link1 link2 .

Weitere Antworten (0)

Kategorien

Mehr zu Historical Contests finden Sie in Hilfe-Center und File Exchange

Gefragt:

Aj
am 15 Feb. 2018

Bearbeitet:

am 22 Feb. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by