tiledlayout doesn't work with uifigure?
Ältere Kommentare anzeigen
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?
Antworten (2)
Ameer Hamza
am 29 Apr. 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 Kommentare
powl
am 29 Apr. 2020
Ameer Hamza
am 29 Apr. 2020
I am not sure why Mathworks suddenly changed this behavior? Have you installed the latest update released recently for R2020a?
powl
am 29 Apr. 2020
Ameer Hamza
am 29 Apr. 2020
Yes, MATLAB does not update automatically. Maybe It was making a normal figure instead of uifigure, but you didn't notice it before.
powl
am 29 Apr. 2020
Ameer Hamza
am 29 Apr. 2020
Were you able to draw the polaraxes over a tile before without using the axes handles? What was the code?
powl
am 30 Apr. 2020
Ameer Hamza
am 30 Apr. 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
am 30 Apr. 2020
Bearbeitet: Paul Hamacher
am 30 Apr. 2020
0 Stimmen
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 Kommentare
Ameer Hamza
am 30 Apr. 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
Paul Hamacher
am 30 Apr. 2020
I couldn't give a better explanation for this behaviour! ?
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
