# How to obtain values from a table in matlab

2 views (last 30 days)
karishma koshy on 14 Jul 2019
Edited: karishma koshy on 15 Jul 2019
I have a table with two columns as circle's centre position and third one with frame number 1-1000. I want to obtain the values of circle centres in frame n and n-1 at a time, inorder to make matrix out of it
How can I do that?

Adam Danz on 14 Jul 2019
Edited: Adam Danz on 14 Jul 2019
I'm not sure what you mean by "in order to make a matrix out of it". If this demo doesn't address the problem, please provide an example. Otherwise, here's how to extract the (x,y) coordinates for a given frame.
%Fake data
T = table((1:9)',(2:10)',[1;1;1;2;2;2;3;3;3],'VariableNames',{'X','Y','Frame'});
f = 2; % frame number
frameIdx = T.Frame == f; %row numbers of frame n
frameIdx = T.Frame == f-1; %row numbers of frame n-1 (not used in this demo)
% FROM HERE YOU CAN DO LOTS OF THINGS LIKE...
% ...isolate rows of table that belong to frame n
T(frameIdx,:)
% ...isolate only the (X,Y) values that belong to frame n
T(frameIdx,{'X','Y'})
% ...put (X,Y) values from frame n into a matrix
T{frameIdx,{'X','Y'}}
I recommend keeping the data in the table rather than extracting it into a matrix unless your analysis requres a matrix.
karishma koshy on 15 Jul 2019
Dear Sir I'm aiming to measure the distance between all points in one frame and all points in the next frame. So I want to
Create a table (let’s call this “table i”)which only contains points in frame i (where “i" is the index of that frame) Create another table (“table i+1”), which only contains points in frame i+1 Create a 2D distance matrix (width equal to the number of points in frame i and height equal to the number of points in frame i+1) where each element is the Pythagoras distance between two points.
How can I implement this as a code ? Thank you