tiledlayout doesn't work with uifigure?
이전 댓글 표시
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?
답변 (2개)
Ameer Hamza
2020년 4월 29일
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
powl
2020년 4월 29일
Ameer Hamza
2020년 4월 29일
I am not sure why Mathworks suddenly changed this behavior? Have you installed the latest update released recently for R2020a?
powl
2020년 4월 29일
Ameer Hamza
2020년 4월 29일
Yes, MATLAB does not update automatically. Maybe It was making a normal figure instead of uifigure, but you didn't notice it before.
powl
2020년 4월 29일
Ameer Hamza
2020년 4월 29일
Were you able to draw the polaraxes over a tile before without using the axes handles? What was the code?
powl
2020년 4월 30일
Ameer Hamza
2020년 4월 30일
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
2020년 4월 30일
편집: Paul Hamacher
2020년 4월 30일
0 개 추천
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
Ameer Hamza
2020년 4월 30일
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
2020년 4월 30일
I couldn't give a better explanation for this behaviour! ?
카테고리
도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
