Matlab 如何操作按钮位置属性?
我正在努力调整按钮的位置。应该没那么难,但不知怎的我想不出来。你知道在哪里添加正确的代码吗Matlab 如何操作按钮位置属性?,matlab,button,Matlab,Button,我正在努力调整按钮的位置。应该没那么难,但不知怎的我想不出来。你知道在哪里添加正确的代码吗 button = 'Continue'; while strcmpi(button, 'Continue') promptMessage = sprintf('Are the results ok?,\nor should the script be stopped?'); titleBarCaption = 'Continue?'; button.Position = [100 10
button = 'Continue';
while strcmpi(button, 'Continue')
promptMessage = sprintf('Are the results ok?,\nor should the script be stopped?');
titleBarCaption = 'Continue?';
button.Position = [100 100 50 20]; %this line seems to the issue
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
下面是一个示例,在
questdlg
提示符下按continue键时,在ui图中随机放置ui按钮。这里,ui按钮
被命名为Test\u按钮
,它独立于字符向量按钮
。由于问题中的详细信息有限,我不确定您是否试图更改questdlg
提示符中按钮的位置
UI_Figure = uifigure;
UI_Figure.Position = [0 0 500 500];
Test_Button = uibutton('Parent',UI_Figure);
Figure_Width = UI_Figure.Position(3);
Figure_Height = UI_Figure.Position(4);
button = 'Continue';
while strcmpi(button, 'Continue')
promptMessage = sprintf('Are the results ok?,\nor should the script be stopped?');
titleBarCaption = 'Continue?';
Test_Button.Position = [round(rand(1)*Figure_Width) round(rand(1)*Figure_Height) 50 20];
%this line seems to the issue
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
行button.Position=…
尝试调整按钮的位置,但此时按钮是一个字符向量(在第一行中定义),因此出现错误请询问特定的编程问题。“询问有关堆栈溢出的问题应该是找到答案过程中的最后一步”非常感谢。这对我有帮助。