【发布时间】:2015-09-17 20:55:54
【问题描述】:
我有一个带有 GUI 的 Matlab 应用程序。 我现在正在尝试自动化一些操作,我需要在 GUI 加载后立即调用一个函数,而没有任何人在循环中。 (基本上是模拟人类的按钮点击...)
我尝试从“_OpeningFcn”和“_OutputFcn”调用想要的函数,但没有成功。
我也尝试点击此链接,但效果不佳:( http://www.mathworks.com/matlabcentral/answers/161545-call-callback-without-mmouse
关于如何在 GUI 完全加载后以编程方式调用函数的任何其他想法?
谢谢!
编辑1: 据我了解,如果我想调用该函数,那么我应该将其放入 “EnergyData_OutputFcn”。 所以,这就是它的样子:
function varargout = EnergyData_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
hGuiFig = findobj('Tag','btnReportGeneration');
EnergyData('btnReportGeneration_Callback',handles.btnReportGeneration,[],handles);
varargout{1} = handles.output;
问题是这个函数被递归调用(我可以在调试时看到它),我最终得到这个错误消息:
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space
can
crash MATLAB and/or your computer.
Error in genvarname>isCellString
这让我想到一个问题,假设我在上面链接中附加的帖子中描述的方法是正确的方法, 我在哪里放置此代码? (我什至在他附在帖子中的示例文件中都找不到它......)
感谢您的帮助!
【问题讨论】:
-
您是如何尝试链接中发布的内容的?它对我来说效果很好。你能发布你的代码吗?
-
谢谢这是我添加的两行代码: hGuiFig = findobj('Tag','btnReportGeneration') ; EnergyData('btnReportGeneration_Callback',handles.btnReportGeneration,[],handles)
-
您介意将这些代码放在您的原始帖子中并描述您尝试调用 GUI 后遇到的错误类型吗?
-
好的,我现在明白了。我从外部脚本调用它,工作起来就像一个魅力:)
标签: matlab matlab-guide