# Extracting Info from the table

1 view (last 30 days)
Turner on 6 Jul 2022
Edited: Rohit Kulkarni on 6 Jul 2022
I have a table for example as below
Team Wins Loss
Ixe 10 5
Tyz 19 1
Fgsd 15 2
I want to access the data from the table but when I do so I get a table back.
For example tb(1,1) i get a table instead of a double. Any help will be appreciated.
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

### Answers (2)

Rohit Kulkarni on 6 Jul 2022
Edited: Rohit Kulkarni on 6 Jul 2022
If you want to access data from multiple variables at once, you can index with curly braces.
Inside the curly braces, you can specify the desired variables by index or variable name.
This will create a numeric array
% for eg
tb_matrix = tb{:, ["Wins" "Loss"]};
%tyz wins
Tyz_wins = tb{2,1}
You can also use dot notation for extraction
tbWins = tb.Wins
%tyz wins
Tyz_wins = tb.Wins(2)
Find the documentation here.
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

Siraj on 6 Jul 2022
Hii, It is my understanding that your are able to make a table and now you want to access the values from the table. There are certain possible ways of doing it.
1. First way is to use the parantheses just as we access the data in the matrices. But keep in mind that whenever you will use parantheses to access the data from a table, the answer will always be a table.
2. You can use the dot notation to extract the data. "tb.Wins" will give you a matrix and then you can use the standard way of accessing the data from a matrix, that is using the parantheses.
3. You can use the curly braces to extract the data. It works in a similar way as paranthesis indexing but the answer is not a table.
I am attaching the example for all the 3 ways mentioned above.
Please refer to the documentation for more on tables.
Hope it helps.
wins = [10, 19, 15]';
loss = [5, 1, 2]';
name = ["Ixe", "Tyz", "Fgsd"]';
arr = [ wins loss ];
tb = array2table(arr,"VariableNames",["Wins","Loss"]);
tb.Team = name;
tb(1,1)
ans = table
Wins ____ 10
tb{1,1}
ans = 10
tb.Wins(1)
ans = 10
##### 0 CommentsShow -1 older commentsHide -1 older comments

Sign in to comment.

### Categories

Find more on Tables in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!