'Error using axes' when I use functions in GUI
Mostrar comentarios más antiguos
I want the plot to be in axes1 of my GUI, but instead, a new figure opnes. This is only the case when I use an own function inside the GUI. This is my Code: (without Inputs)
if true
% code
...
x = linspace(0,L,n); % Knotenvektor
[S, M] = systemmatrizes(x, E, I, mu);
bc = [1, 1, a; 1, 2, b; n, 3, 0; n, 4, 2];
[Me, Se, r] = linearsystem(x, M, S, q, bc, m);
y = Se\r;
wa = y(1:2:2*n);
axes(handles.axes1);
plot(x,wa)
axis([0 1.1*L -1 1],'square');
end
And this is the Error:
_Error using axes Invalid axes handle
Error in BalkenbiegungGUI>togglebutton1_Callback (line 266) axes(handles.axes1);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in BalkenbiegungGUI (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)BalkenbiegungGUI('togglebutton1_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating DestroyedObject Callback.__
Line 266 is axes(handles.axes1); If I don't use my functions systemmatrices and linearsystem, it works. But I need them. What am I doing wrong?
7 comentarios
Christian Dieterich
el 5 de Abr. de 2018
Editada: Christian Dieterich
el 5 de Abr. de 2018
Hello,
where are the variables mu and m in the Callback Function defined? Better is sharing the whole Code and all functions that i can try.
plot( handles.axes1, x,wa )
would be a far better way of making sure you plot on the axes you want, though that will not solve the error you have as in your case it appears that handles.axes1 is no longer an axes.
What do you get on command line if you put a breakpoint in and type
handles.axes1
before that line? And what do you get if you do the same before the call to systemmatrizes?
Peter Dauksch
el 6 de Abr. de 2018
Adam
el 6 de Abr. de 2018
So what do you get when you use breakpoints and type the things I asked on command line at the relevant points in the code?
Peter Dauksch
el 6 de Abr. de 2018
Adam
el 6 de Abr. de 2018
Unless you have done some really bad things in other functions of your GUI or have corrupted your .fig file you should never have a deleted axes in a GUIDE GUI (unless you deliberately delete it which would be a bizarre thing to do usually!).
Check you don't have things like
clear all
or other sledgehammer type functions in your GUI file.
Peter Dauksch
el 6 de Abr. de 2018
Respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!