Unrecognised handles in set

4 views (last 30 days)
Alex
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
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?

Sign in to comment.

Answers (1)

Fangjun Jiang
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.
  8 Comments
Fangjun Jiang
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
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.

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!