@findall in an arrayfun?
显示 更早的评论
Hi,
I'm having trouble using findall as an arrayfun. In AppDesigner, I'd like to find all objects whose 'Tag' has 'img' in it - I have lots of uiimages, img_1, img_2... img_25, and then run a function on all these uiimages?
I've tried the following:
arrayfun(@findall,0, 'Tag', a);
where a = is a cell array of strcat of 'img_' + num2str(n);
a = cell(25,1);
for i = 1:25
a{i} = strcat('img_',num2str(i));
end
Thanks!
采纳的回答
更多回答(1 个)
As written this will find all graphics objects with those Tag values, those that are part of your app and those that are not. That strikes me as a Bad Idea. Instead, if you're displaying those images in your app I'd store their handles in a property of your app and then simply iterate through the elements of that property. This example doesn't use an app but shows the technique I have in mind.
f = figure;
ax = axes('Parent', f);
axis([0 360 -1 1])
hold on
x = 0:360;
h = gobjects(1, 5);
for k = 1:5
h(k) = plot(x, sind(k*x), 'DisplayName', "sine of " + k + "*x");
end
legend show
Now I can change a subset of the lines without using findobj or findall just by indexing into h.
h(1).LineStyle = '--';
h(3).Color = 'k';
h(5).Marker = '^';
h(5).MarkerIndices = 1:30:361;
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
