Reputation: 790
I have a struct array Imgs
and it includes following properties of image files inside each struct.
name
date
byte
isdir
datenum
now I want to create a new string array img_names
that includes the only names of the above struct array. I am really a newbie about matlab and I don't get how to do it.
So I want to have a array like in that structure.
img_names[1] = 'file-1.jpg'
img_names[2] = 'file-2.jpg'
img_names[3] = 'file-3.jpg'
...
Upvotes: 2
Views: 1636
Reputation: 11168
img_names = arrayfun(@(x) x.name,Imgs,'uni',false)
produces a cell array containing the names. You can then access each name using:
img_names{1}
img_names{2}
% ...
Upvotes: 1