My gui closes during simulation and when reopen the image on the axes doesnt show up. Help

2 次查看(过去 30 天)
My gui calls .m file (Name: fopi_gui) to simulate values and store in the workspace for the gui to pull out and display in the GUI window; see image below
My issues are as follows:
When I Click to save & Run the gui, the GUI window closes automatically and displays the required graphs from the .m file. How can i stop this from closing the GUI and after simulation i should use the output pushbutton to display them???
---> i have already tried different figure numbers but didnt solve the issue.
After the required plots have popped up on my screen (i.e step response, bode plot) by placing the command at the end of the .m file of simulation...
open('fopi_gui.fig')
...im able to open the GUI again automatically to solve this above issue temporarily, but the image becomes a clear axes as shown in the image below (apart from the image which was their initial)
Using the pushbuttom, OUTPUT, i cant display the values until i close the gui and open it again.
the error showing is below when after it automatically opens is and when i press OUTPUT
Attempt to reference field of
non-structure array.
Error in fopi_gui>out_Callback (line
125)
set(handles.Kp,'string',A);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in fopi_gui (line 42)
gui_mainfcn(gui_State,
varargin{:});
Error in @(hObject,eventdata)fopi_gui('out_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
after closing and opening the GUI by going to the command window and typing the fopi_gui name, i can use the OUTPUT pushbutton and display the values as shown below.
The codes for the GUI is given below:
1. For the image to display Gplant(s)
% --- Executes just before fopi_gui is made visible.
function fopi_gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
X = imread('plant.png');
axes(handles.axes1);
imshow(X)
axis off
How can i solve the issues?? Please help. I will provide more clarification where required. But please help. More codes on the GUI are below in this post.

回答(1 个)

Nitesh
Nitesh 2015-11-17
2. To use pushbutton RUN to call and run the .m file
function run_Callback(hObject, eventdata, handles)
open('DCServo_FOPITuning.m')
run('DCServo_FOPITuning.m')
assignin('base','y1',y1)
assignin('base','Kp',Kp)
assignin('base','Ki',Ki)
assignin('base','lemda',lemda)
assignin('base','w90',w90)
3. To display the values after opening the GUI AGAIN.
function out_Callback(hObject, eventdata, handles)
A = evalin('base','Kp');
set(handles.Kp,'string',A);
B = evalin('base','Ki');
set(handles.Ki,'string',B);
C = evalin('base','lemda');
set(handles.lemda,'string',C);
D = evalin('base','w90');
set(handles.w90,'string',D);
4. To save the input names to workspace to .m file to use from
% --- Executes on button press in Tbrkth.
function Tbrkth_Callback(hObject, eventdata, handles)
k = str2double(get(handles.k,'String'));
tau = str2double(get(handles.tau,'String'));
theta= str2double(get(handles.theta,'String'));
ms = str2double(get(handles.cv,'String'));
level = str2double(get(handles.level,'String'));
%Calculate Tbrkth and set answer to static text box Tbrkth
Tbrkth = ('Saved');
set(handles.Tbrkth,'String',Tbrkth);
%Save Tbrkth and other variables to workspace
assignin('base', 'k', k);
assignin('base', 'tau', tau);
assignin('base', 'theta', theta);
assignin('base', 'ms', ms);
assignin('base', 'level', level);
save('parameters.mat','k','tau','theta','ms','level','Tbrkth');
Please help!!! urgent.. thnk you

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by