GUI project in mat lab

Discussion in 'Programmer's Corner' started by m75allen, Nov 29, 2006.

  1. m75allen

    Thread Starter Member

    Nov 20, 2006
    11
    0
    Hi guys, i have a project i have been working on for a couple of weeks in mat lab. i am designing a GUI in mat lab and i have been getting these errors, and since i have never used mat lab before i am learning as i go. Here are some of the errors i have been getting.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn
    Expression or statement is incorrect--possibly unbalanced (, {, or [.

    I also need to know how to link my callbacks to other codes i have.
    Any help will be greatly appreciated. Thanks
     
  2. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    143
    uicontrol CreateFcn is the callback executed when creating an object (most probably the UI window). The error Expression or statement is incorrect--possibly unbalanced (, {, or [ means that there is some code after CreateFcn is placed within a set of mismatched parenthesis, for example (underlined):

    Code ( (Unknown Language)):
    1. function uifcn_CreateFcn(hObject,eventdata,handles)
    2.  
    3. pos=get(gcbf,'Position');
    4. delete[U](gcbf;[/U]
    You need to do a through step through of your code to remove such errors. Be careful of multiple parenthesis embedds, e.g. (code(code(code))code()) - look for the indicators under each bracket when you place your cursor on it.

    I would also suggest, if you haven't done so already, have a look the GUIDE video tutorials in Matlab, go to Matlab Start>MATLAB>Demos - there are many demos including a demo of using GUIDE, although you most probably be familiar with most of what it tells you.

    Any further questions let us know. It may also be an idea to give a brief overview of your UI/software design and how the functions interact - have you done a high-level software deisgn diagram?

    Dave
     
  3. m75allen

    Thread Starter Member

    Nov 20, 2006
    11
    0
    I am still having the same problem, i had abadoned the project for a while but now i want to finish it. i was able to program most call backs but i am still having errors when i try to run the GUI. The errors am getting are:
    open('F:\WxRgood\WxR.fig')
    ??? Error: This statement is incomplete.

    ??? Error using ==> WxR('ClosePushButton_CreateFcn',gcbo,[],guidata(gcbo)

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    ??? Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> WxR('nmiRangeTextbox_CreateFcn',gcbo,[],guidata(gcbo))
    Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    ??? Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> WxR('RangeBinsPerRadialTextbox_CreateFcn',gcbo,[],guidata(gcbo))
    Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    ??? Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> WxR('RadialsPerScanTextbox_CreateFcn',gcbo,[],guidata(gcbo))
    Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    ??? Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> WxR('scanNumberTextbox_CreateFcn',gcbo,[],guidata(gcbo))
    Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    ??? Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> WxR('WxRfilenameTextbox_CreateFcn',gcbo,[],guidata(gcbo))
    Error: File: WxR.m Line: 300 Column: 1
    The function "ProcessDataPushButton_Callback" was closed
    with an 'end', but at least one other function definition was not.
    To avoid confusion when using nested functions,
    it is illegal to use both conventions in the same file.

    ??? Error using ==> struct2handle
    Error while evaluating uicontrol CreateFcn

    >>
     
  4. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    143
    Sub-functions in Matlab need to be closed with an 'end' statement. Although the callback is a type of sub-function of the m-file for a corresponding UI fig-file, it is convention not to close the function with an 'end' statement. Therefore remove it at Line 300 in WxR.m.

    Dave
     
  5. m75allen

    Thread Starter Member

    Nov 20, 2006
    11
    0
    Thanks Dave. In my WxR.m file i dont have a line 300 and thats what is confusing me. My M file goes up to line 237.
     
  6. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    143
    Sounds like your m/fig-file pair for the UI have been corrupted. It's starting from scratch I'm afraid.

    Dave
     
  7. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    3
    Do you have any other WxR.m file in Matlab registered search paths? Try deleting the file, after making a backup, and see whether Matlab still finds the file.
     
Loading...