MATLAB Answers

0

How to call a function from app designer? and also make it graph in the axes inserted in app designer

Asked by Laura Mazuera on 9 Dec 2018 at 0:49
Latest activity Commented on by Cris LaPierre on 9 Dec 2018 at 3:17
We have a function that works perfectly when we call it from the command window, the function takes a structure and graphs it components in the figure window. We want to be able to call it from app designer and make it graph the components in the axes inserted there instead of the figure window. Any recommendations?

  0 Comments

Sign in to comment.

1 Answer

Answer by Cris LaPierre on 9 Dec 2018 at 3:08

You can call external function in app designer (see here). The challenge is going to be getting it to plot in the app. You could try adding an input to your function that is an axes handle. Then in your function, try specifying the axes handle in your plot command. When you call the function with the app axes handle, give it the app axes handle and see if it can plot to your app.

  1 Comment

Ok, was too curious not to test it myself. It works.
The external function
function plotToApp(x,y,h)
plot(h,x,y)
end
Calling it in app designer
function Button2Pushed(app, event)
x=1:10;y=(x-5).^2;
plotToApp(x,y,app.UIAxes)
end

Sign in to comment.