Unrecognised handles in set
Mostrar comentarios más antiguos
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 comentario
Jan
el 11 de Oct. de 2011
Somehow you seem to use a variable |handles| without the fiels |output_pump_freq|. How do you set (and store) the |handles| variable?
Respuestas (1)
Fangjun Jiang
el 11 de Oct. de 2011
0 votos
"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 comentarios
Alex
el 11 de Oct. de 2011
Walter Roberson
el 11 de Oct. de 2011
Maybe in theory, but I haven't seen anyone do it. By the time you got through the changes and restrictions you would need to deal with for this, you might as well just skip using GUIDE.
Jan
el 11 de Oct. de 2011
I do not understand the benefit of double clicking on the FIG file. This question appears repeatedly and I'm more and more confused, why users want to do this. Why is clicking FIG files such appealing?
Fangjun Jiang
el 11 de Oct. de 2011
@Jan, because, at least from one OP, his professor insists to be able to double click a file and run the file. If he double clicks the .m file, an editor with the .m code will be brought up and the professor will be confused. It's even more confusing if the professor has to start MATLAB, right click the .m file and then click 'Run'.
Walter Roberson
el 11 de Oct. de 2011
Provide a batch or shell script that starts matlab with the -r option?
Jan
el 12 de Oct. de 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
el 12 de Oct. de 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
el 12 de Oct. de 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.
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!