How to fix this erro in GUIDE?

8 次查看(过去 30 天)
Daniel Fonsêca
Daniel Fonsêca 2018-9-18
评论: Rik 2018-9-25
I'm using the Guide to build a programme and i have had the following problem: "Functions are nested too deep" I put the "end" at the end the functions, but it doesn't work. Can you help me? I have more than 15 functions

回答(1 个)

Rik
Rik 2018-9-18
编辑:Rik 2018-9-18
Either end all functions with the end keyword, or end none of them with the end keyword. The default that GUIDE uses is not using end, as that was the standard in Matlab (it would even trigger a warning if you didn't). Currently the standard is to end all functions with end, especially since you are allowed to use local functions in a script.
If you have trouble making the edit, just attach your code and I'll make the edit.
  3 个评论
Daniel Fonsêca
Daniel Fonsêca 2018-9-25
It didn't solve my problem. I'm remaking it. But, thanks by your attention.
Rik
Rik 2018-9-25
If you're remaking it, then I would suggest avoiding GUIDE in the first place. I could still try to do the edit if you like.
My small guide to avoid GUIDE:
  • Make a figure (with f=figure;) and look into the doc for figure which properties you want to turn off (you probably want to set Menu and Toolbar to 'none')
  • Create buttons and axes and everything you need with functions like uicontrol and axes. Save the handles to each element to fields of a struct (like handles.mybutton=uicontrol(_);)
  • When you've finished loading all data (and saving it to fields of your handles struct), and creating all the buttons, save your handles struct to the guidata of your figure like this guidata(handles.f,handles);. (You can also use getappdata and setappdata)
  • You can set the Callback property of many objects. If you do, use a function name with an @ in front, or a char array that can be evaluated to valid code. (like @MyFunction or 'disp(''you pushed the button'')')
  • Callback functions will be called with two arguments: the first is a handle to the callback object, the second is eventdata that may contain special information. To get access to your data, just use handles=guidata(gcbo);. You can replace the gcbo function with the name of the first input to your callback function if you prefer.
  • More information about callbacks can be found in multiple places in the doc, for example here.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by