0

UIAxes in Matlab App designer does not support non-numeric data such as a graph plot, is there any alternative to do it inside UI framework?

In GUIDE I do this:

% --- Executes on button press in Visualize.
function Visualize_Callback(hObject, eventdata, handles)
a = [1 2 3 4];
b = [2 3 4 1];
g = graph(a,b);
p = plot(g);
axis off

Clicking for example Visualize button I'll have the graph appeared in the guide fig. framework. enter image description here

I try to do that in App Designer and it's ok for plotting numeric values, but for a graph visualization I didn't find the right way to do so.

methods (Access = private)

    % Button pushed function: VisualizeButton
    function VisualizeButtonPushed(app, event)

        a = [1 2 3 4];
        b = [2 3 4 1];

        g = graph(a,b);
        ax = app.UIAxes;

        plot(ax,g)
    end
end

enter image description here

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
Shivid
  • 1,295
  • 1
  • 22
  • 36
  • Which MATLAB version is this? The App Designer is one of the modules that constantly receives attention in [MATLAB releases](https://www.mathworks.com/help/matlab/release-notes.html?rntext=&startrelease=R2016a&endrelease=R2017a&category=App+Building&groupby=release&sortby=descending&searchHighlight=). Unfortunately for us users, its functionality is still limited with respect to "regular" figures. One of the solutions would be to update your MATLAB version, in hopes that the desired functionality was added at later releases. Regardless, please provide a [mcve] so we can reproduce your error. – Dev-iL Mar 13 '17 at 12:37
  • This is 2016a, academic use. You are right that the App Designer is a very interesting module but I'm a beginner and naturally I expect similar functionality of Guide. I'll update my question explaining what I used to do in Guide. – Shivid Mar 13 '17 at 19:57
  • 1
    Note that `plot(graph)` support was only added in [R2017a](https://www.mathworks.com/help/matlab/creating_guis/graphics-support-in-app-designer.html). – Dev-iL Mar 13 '17 at 21:32
  • I see, actually this is what I was trying to understand, Thanks. – Shivid Mar 13 '17 at 23:00

1 Answers1

1

As mentioned in my comment, support for plotting graph objects in the app designer was only added in R2017a1, 2.

Unless you want to go through the trouble of re-implementing graph yourself using plotting functions available in R2016a (this is probably WAY beyond the scope of an answer), you should just update your MATLAB version.

Dev-iL
  • 23,742
  • 7
  • 57
  • 99