Reputation: 1547
A MATLAB struct was created:
filenameSubstring='C:\Data\**/*.json';
filenames = dir(filenameSubstring);
The attempt to evaluate the mean was unsuccessful:
sizemean = mean(filenames.size);
Attempts to create an array was not successful in that it returned only one value:
test=(filenames(:).bytes)
I could put the access the each element using a for loop:
for i= 1:size(filenames,1)
test(i)=filenames(i).bytes;
end
Is there a concise one-liner that can move all .bytes elements into an array for further evaluation?
Upvotes: 1
Views: 57
Reputation: 60780
Yes:
[filenames.bytes]
filename.bytes
generates a comma-separated list of values, equivalent to filename(1).byes, filename(2).bytes, filename(3).bytes, ...
. The square brackets concatenate these into an array. The above is thus the same as
[filename(1).byes, filename(2).bytes, filename(3).bytes, ... ]
Upvotes: 5