Hi! The code below shows two different examples of taking a UIAxes object as an input to a function. I'm unclear as to whether you want to plot a bunch of scatter points to one UIAxes object or if you want to plot a single point to each of multiple UI Axes objects, so here are solutions to both:
Situation 1:
I made a small test app to work through your function. I have this setup so that it runs the bplot function when you press the button and all the scatter points are plotted on this one specified UIAxes object. See the code pieces below:
function ButtonPushed(app, event)
x=1:5;
y=1:5;
bplot(app, app.UIAxes, x, y);
end
function results = bplot(app, axisObj, x, y)
scatter(axisObj, x, y);
end
Situation 2:
When you press the button, one scatter point is plotted on the first UIAxes and the next scatter point is plotted on the second UIAxes.
properties (Access = private)
AxesStorage
end
function startupFcn(app)
app.AxesStorage={app.UIAxes, app.UIAxes2};
end
function ButtonPushed(app, event)
x=1:2;
y=1:2;
bplot(app, app.AxesStorage, x, y);
end
function results = bplot(app, axisObj, x, y)
for i=1:length(x)
scatter(axisObj{i}, x(i), y(i));
end
end
If you want to plot all the scatter points on both UI Axes you could change the bplot function to be the following:
function results = bplot(app, axisObj, x, y)
for i=1:length(axisObj)
scatter(axisObj{i}, x, y);
end
end
Hope this helps!