The following code demonstrates the problem:
hFigure = figure;hButton = zeros(2,1);for k = 1:2hButton(k) = uicontrol('parent',hFigure,'position',[10 100-40*k 60 40],'string',int2str(k));endfprintf('Strings of text controls "hButton":\n');get(hButton, 'String')
The output of the above code is as follows:
Strings of text controls "hButton": ans = '1' '2'
Now, using COPYOBJ as follows:
hFigure2 = figure;hButton_Copied = copyobj(hButton,hFigure2);set([hButton(1), hButton_Copied(1)],'selected','on'); fprintf('Strings of text controls "hButton":\n');get(hButton_Copied, 'String')
gives a reversed output:
Strings of text controls "hButton": ans = '2' '1'
Best Answer