Using cellfun() to set cell array of graphic objects 'Visible' Property to 'off'

1 次查看(过去 30 天)
I have a 1xn cell array of graphic objects-- currently I have the logic in a for-loop
for j = 1:numel(uis)
uis{j}.Visible = 'off';
end
I've always had trouble with the syntax for the cellfun function...I know this is wrong, but I'm trying to do something like:
cellfun(@set,uis,'Visible','off')
*note: found out here:
that for loops are faster than cellfun(), but I would like to know the answer to my question anyway :)

采纳的回答

Stephen23
Stephen23 2019-2-12
编辑:Stephen23 2019-2-12
You will need to define an anonymous function like this:
cellfun(@(g)set(g,'Visible','off'),your_cell_array_of_handles)
Note that you could easily have put all of the handles into one handle array, in which case your code is much simpler and more efficient:
set(array_of_handles,'Visible','off')
  4 个评论
Kevin Phung
Kevin Phung 2019-2-13
Did not know you can concatenate uis{:} in that way with [], this will be very useful knowledge-- thanks Jan!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by