MATLAB Answers

How to convert a numeric array to a table.I want the first row of data of the array to be J and the second row of data to be K in a table T[J K];

1 view (last 30 days)
>> A=imread('C:\Users\ADMIN\Desktop\canada.bmp');
>> level=graythresh(A);
>> B=im2bw(A);
>> O=imcontour(B);
I'm building this code and the last command returns an array wich has two rows of data!These data are the points of contoured image invariants.I want to create a table which will take the first row of data as J and the second row as K in a new table T[J K];Don't mind if it's double or unit8 or something else.Please help!!

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 29 Aug 2016
array2table(O.', 'VariableNames', {'J', 'K'});
Single letter variable names / column names are not good practice. Use variable names that have meaning.

  4 Comments

Show 1 older comment
Guillaume
Guillaume on 29 Aug 2016
Please, see the help on working with tables
mytable = array2table(O.', 'VariableNames', {'J', 'K'});
mytable(1, :) %return 1st row of mytable as a table
mytable.J(1) %return 1st element of column J

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 29 Aug 2016
A=randi(10,2,5)
names={'J','K'}
cell2table(num2cell(A'),'VariableNames',names)

Sign in to answer this question.