Using a generated variable name as a handle for set function
2 次查看(过去 30 天)
显示 更早的评论
Hello!
I would like to know how can I use a generated variable name to be used as a handle for the SET function. I have the current code:
for j=1:25
var=num2str(j, '%02i')
variable=['panel31.txt1' var]
if timematrix(menu.pm28, j)==1
set(variable, 'Color', 'g');
else
set(variable, 'Color', 'r');
end
end
However, I am getting the following error:
Error using set
Value must be a handle
How can I do this?
0 个评论
采纳的回答
Walter Roberson
2015-9-14
for j=1:25
var=num2str(j, '%02i')
variable = sprintf('txt1%02i', j);
if timematrix(menu.pm28, j)==1
set(panel31.(variable), 'Color', 'g');
else
set(panel31.(variable), 'Color', 'r');
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Christmas / Winter 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!