Creating table with array in element
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Philip Shaw
am 2 Jun. 2021
Kommentiert: Walter Roberson
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu LaTeX finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
