非模态questdlg.m提示

时间:2014-05-16 14:56:59

标签: matlab modal-dialog

我的代码制作了一个情节,然后提示用户是否要制作另一个不同参数的情节。问题是,当questdlg.m打开时,用户无法查看图上的详细信息。

以下是代码:

while strcmp(Cont,'Yes') == 1

    %Some code modifying 'data'

    plot(1:X,data);
    Cont = questdlg('Would you like to plot another pixel?','','Yes','No','Yes');
    close all;

end

我尝试了一些事情。我尝试创建另一个名为normalquestdlg.m的函数,然后我将questdlg.m代码粘贴到其中,修改第401行。

set(QuestFig,'WindowStyle','modal','Visible','on');

set(QuestFig,'Visible','on');

我尝试了normalquestdlg.m函数的不同位置。将它放在我自己函数的默认Matlab文件夹中会给我带来以下错误:

Undefined function 'dialogCellstrHelper' for input arguments of type 'char'.

Error in **normalquestdlg** (line 74)
    Question = dialogCellstrHelper(Question);

Error in **Plot** (line 40)
    Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');

将它放在与questdlg.m相同的文件夹中(C:\ Program Files \ MATLAB \ R2014a \ toolbox \ matlab \ uitools)给了我以下错误:

Undefined function 'normalquestdlg' for input arguments of type 'char'.

Error in **Plot** (line 40)
    Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');

我甚至试图把它作为寻找的第一条路径:

p = path
path('C:\Program Files\MATLAB\R2014a\toolbox\matlab\uitools', p)
Cont = normalquestdlg('Would you like to plot another pixel?','','Yes','No','Yes');
path(p)

毋庸置疑,这并没有改变一件事。

任何人对我有任何提示?

1 个答案:

答案 0 :(得分:2)

没有找到简单的解决方案。我能找到的最简单的事情是下载MFquestdlg.m(http://www.mathworks.com/matlabcentral/fileexchange/31044-specifying-questdlg-position/content/MFquestdlg.m)并以这种方式修改它的第384行:

set(QuestFig, 'WindowStyle', 'modal', 'Visible', 'on');

set(QuestFig, 'Visible', 'on');

因为'正常'是默认的WindowStyle。

我更喜欢这样做,而不是修改基本的Matlab函数。通过在指定WindowStyle的函数中添加一个输入(正常','模态'或者'),可以进一步增强(如果有人需要这样做)。停靠'),这将非常容易,在这种风格中添加了一些像防线一样的防错:

if nargin < 8
    WinStyle = '%enter default mode'
end
if nargin == 8
    if strcmp(WinStyle,'normal') == 1 | strcmp(WinStyle, 'modal') == 1 | strcmp(WinStyle, 'docked') == 1
    else
        error('MATLAB:questdlg:IncorrectInput', 'The WindowStyle input parameter was incorrectly written')
    end
end