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

33 views (last 30 days)
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?

Answers (1)

Cris LaPierre
Cris LaPierre on 9 Dec 2018
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
Cris LaPierre
Cris LaPierre on 9 Dec 2018
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.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!