Creating table with array in element
4 views (last 30 days)
Show older comments
Philip Shaw
on 2 Jun 2021
Commented: Walter Roberson
on 2 Jun 2021
I am trying to create a table which includes an array in each row (like the output from regionprops etc.)
I know how to do it by creating a struct and using struct2table, but is there are way to create a blank table with an array variable using the table('Size', [..], 'VariableTypes', ...) constructor?
I have tried searching but any useful results are buried under posts about array2table.
0 Comments
Accepted Answer
Walter Roberson
on 2 Jun 2021
You do not need to do anything special. Once the variable exists, you can write over the content with an array
t = table('Size', [3 2], 'VariableTypes', {'uint8', 'double'})
t.Var2 = zeros(3, 2)
The only challenge would be to have a variable created in the table to have an initial size that has multiple columns; there is no provision for doing that as one step (other than calling table() and passing in content of the appropriate size.)
2 Comments
Walter Roberson
on 2 Jun 2021
You can see that regionpops does it by using cell() for the multi-row entries.
img = imread('cameraman.tif');
bw = img > 224;
imshow(bw)
props = regionprops('table', bw, 'area', 'centroid', 'extrema')
varfun(@class, props)
More Answers (0)
See Also
Categories
Find more on LaTeX 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!