I have created a GUI with 3 axes: axes1
, axes2
, axes3
. I have a class SP
to whose constructor I pass the three axes as follows:
a=SP(handles.axes1,handles.axes2,handles.axes3)
The class looks something like
class SP < handles
properties
axes1
axes2
axes3
end
methods
function A=SP(axes1,axes2,axes3)
A.axes1=axes1;
A.axes2=axes2;
A.axes3=axes3;
axes(A.axes1);
rectangle('Position',[randn,randn,randn,randn]);
axes(A.axes2);
rectangle('Position',[randn,randn,randn,randn]);
axes(A.axes3);
rectangle('Position',[randn,randn,randn,randn]);
end
I have written a timer function
function timerfcn1(~,~,A)
axes(A.axes1);
rectangle('Position',[randn,randn,randn,randn]);
axes(A.axes2);
rectangle('Position',[randn,randn,randn,randn]);
axes(A.axes3);
rectangle('Position',[randn,randn,randn,randn]);
end
My problem is that during the initialization i.e when i call the constructor, the rectangles are plotted in the GUI window. However, whenever the timerfcn1
runs it creates a new figure and plots the rectangle in that.
I had used a similar thing before and it used to work then.