Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Unrecognised handles in set

Asked by Alex on 11 Oct 2011

I'm trying to write a GUI which takes values from four input boxes and performs a calculation then sends the calculated values to four separate static text boxes. I am able to read the information from the input boxes fine and perform the calculation. The problem comes when I try and get the m file to set the values of the four static text boxes using

pump_result=num2str(pump);
set(handles.output_pump_freq,'String',pump_result);

I get an error saying "Reference to non-existent field 'output_pump_freq'.

This only happens when I run the program without debugging it. When I debug just before and run through these steps then the code works fine. It then works whenever I try to run this afterwards so long as I don't close the GUI. When I close the GUI the same problem occurs until I have run the program in debug mode. Have I not defined something properly?

1 Comment

Jan on 11 Oct 2011

Somehow you seem to use a variable |handles| without the fiels |output_pump_freq|. How do you set (and store) the |handles| variable?

Alex

Products

No products are associated with this question.

1 Answer

Answer by Fangjun Jiang on 11 Oct 2011

"This only happens when I run the program without debugging it." Did you double click the .fig file in Windows Explorer to run it? If that is the case, the handles of the GUI is not properly initialized. Try to run the corresponding .m file for the GUI directly.

http://www.mathworks.com/matlabcentral/answers/17138-able-to-run-gui-from-guide-command-interface-but-not-when-opening-fig-straight-in-folder

8 Comments

Jan Simon on 12 Oct 2011

@Fangjun: Thanks for the explanation. Couldn't we patch the professor?
@Walter: The FIG file is a MAT file, such that it is actually a struct. If double clicking the FIG file opens a figure, an interpreter must have been started implicitely. Then the CreateFcn should be able to perform a proper initialization. Do I understand correctly, that only GUIDE is does not know, how to insert the initialization code in the required callback?
I never use GUIDE. When I need to double click on an icon, I compile a stand-alone application, or a batch with -r. So I'm just asking, because the evergreeny fig-file clicking seems to be trivial and unsolved.

Fangjun Jiang on 12 Oct 2011

Did you guys notice that the link in my answer is mathworks.fr (assume France)? If I click that link, I won't be able to edit it. The page indicates I am not logged in.

Walter Roberson on 12 Oct 2011

@Fangjun: just replace the .fr with .com to get the page you want.

@Jan: I have not traced down whether it would be the CreateFcn or OpenFcn that would be involved. Either way, which-ever function, would have to refer to a function that is coded as a series of commands in a string in the appropriate Callback, or is coded as a function handle that is either already in scope or can be brought in to scope (e.g., because it is a separate .m file). I haven't tracked down the extent to which a function body itself is stored if you store a function handle in the .mat file.

Fangjun Jiang

Contact us