tiledlayout doesn't work with uifigure?
37 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I just encountered a strange behaviour. I recently programmed a script witch uses a tiledlayout within an uifigure. It worked well so far until today, when Matlab refuses to apply the tiledlayout onto the already opened uifigure but instead opens a separate figure.
fig = uifigure;
tiledlayout(1, 2);
nexttile(1)
plot(0)
nexttile(2)
plot(0)
That's a demoscript witch provokes the described behaviour. As soon as tiledlayout gets called a new figure opens and the uifigure is ignored. I wrote my script in Matlab R2019b but also upgraded to a fresh R2020a today. Same behaviour. I can't tell why it worked well so far but suddenly started to behave strangely as of today. Any clues?
0 commentaires
Réponses (2)
Ameer Hamza
le 29 Avr 2020
Explicitly specify the handles of graphic objects
fig = uifigure;
t = tiledlayout(fig, 1, 2);
ax = nexttile(t);
plot(ax, 0)
ax = nexttile(t);
plot(ax, 0)
9 commentaires
Ameer Hamza
le 30 Avr 2020
It is quite strange that you were able to make such a thing in uifigure yesterday. I tried to make polaraxes over the tiledlayout, and it is proving to be quite difficult. The following code shows a workaround. Maybe you can file a bug report (not sure, if it is a bug or intended behavior ?) or at least a feature request to make the process of creating polaraxes over tiledlayout in uifigure a bit easier.
fig = uifigure;
ldbtn = uibutton(fig);
ldbtn.Position = [360 30 60 22];
ldbtn.Text = 'Rnd';
svbtn = uibutton(fig);
svbtn.Position = [440 30 60 22];
svbtn.Text = 'Save';
n=100;
rho = linspace(0, 2*pi, n);
axx = [1 n -0.3 0.3];
t = tiledlayout(fig, 5, 3);
ax = nexttile(t,1);
p11 = plot(ax, 0);
p11.YDataSource = 'sin1';
t11 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,4);
p12 = plot(ax, 0);
p12.YDataSource = 'sin2';
t12 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,7);
p13 = plot(ax, 0);
p13.YDataSource = 'sin3';
t13 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,10);
p14 = plot(ax,0);
p14.YDataSource = 'sin4';
t14 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,13);
p13 = plot(ax,0);
p13.YDataSource = 'current_flip';
title(ax,'sum');
axis(ax,axx);
ax = nexttile(t,[5 2]);
ax.Visible = 'off';
pax = polaraxes(fig);
pax.Position = ax.Position;
p2 = polarplot(pax,1, 1);
axis(ax,[1 361 -1 1]);
p2.YDataSource = 'current';
Paul Hamacher
le 30 Avr 2020
Modifié(e) : Paul Hamacher
le 30 Avr 2020
Thank you for you effort! I think the problem arises from the fact, that I try to combine "old" (GUIDE, figure) and "new" (appDesigner, uifigure) GUI elements together in the first place. I think tiledlayout isn't inteded to work with uifigure. I can't tell why it worked at first and then suddenly stopped working. ?
I will try to re-implement my GUI with only new GUI elements (uigridlayout instead of tiledlayout...). Maybe this is easier. This was the first time I worked with gui elements. Compared to other programming environments, GUI programming seems a bit hard to me in Matlab.
2 commentaires
Ameer Hamza
le 30 Avr 2020
Yes, making older graphical elements to work with the uifigure can be a bit of pain. You can try to use uigridlayout since it was specifically made for uifigure. The only thing I find confusing is why it was working before since you didn't even update MATLAB, so there shouldn't be any major changes. I don't think there is a physical explanation for this. Something supernatural must be going on with your system :D
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
