How to show graph plot in app.UIAxes?

Hi, I'm using R2016a.
I have a code in m file like the following
a = [1 1 2 2 2 3 5];
b = [2 3 3 4 6 5 6];
bobot = [0.7 3.8 3.7 2.1 1.6 4 1.8];
C = graph(a,b,bobot);
p=plot(C,'EdgeLabel',C.Edges.Weight);
If I run this code in an m file, it will be very easy for me to get a graph plot like the following
then I want to display this in axes in the app designer as shown below
however, I get an error message like the following.
How can I display the graph plot in my app.UIAxes?

 Accepted Answer

Cris LaPierre
Cris LaPierre on 28 Mar 2021
Edited: Cris LaPierre on 28 Mar 2021
This may be version-specific issue. Your code works fine in R2021a. I don't have R2016a installed to test. I did test it in R2017a, the oldest version I have installed. It worked.
Do you have the ability to update? If not, perhaps try restarting MATLAB?

5 Comments

so this code is working in 2017a? did you install all of its products when you installed the Matlab product? because I only installed a few products. I also can't update my matlab yet
Are you sure you added app.UIAxes to
p = plot (C, 'EdgeLabel', C.Edges.Weight);
so that
p = plot (app.UIAxes,C, 'EdgeLabel', C.Edges.Weight);
?
Thank you for checking. Yes, I'm sure.
You only need MATLAB to run your code, as the plot and graph functions are included in base MATLAB.
I installed R2016a today and confirmed that the code as written will cause an error. The issue appears to be that, in R2016a, uiaxes did not support graphs (your variable C).
The plot command plots into axes while app designer uses uiaxes. They are not the same thing, although each release brings them closer together.
Support for plot(graph) was was added in R2017a (see here). If you want to use app designer, the only soluiton is to update to at least R2017a.
It work now. I've installed 2021a. But I have new peoblem. Maybe it's just a matter of memory capacity of my PC or maybe some other problem.
loading app.UIAxes doesn't stop like the following image
and I can't edit these UIAxes, can't grab, zoom, etc. including delete, as shown below
I don't know if you have any other ideas regarding this. But I would like to uninstall other products that are not related to this project. Therefore, do you know which product I should maintain? and If you have any other ideas regarding this app.UIAxes please let me know.
As I said, you only need MATLAB.
I'm not sure what is happening here. I would suggest contacting customer support.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2016a

Community Treasure Hunt

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

Start Hunting!