Guide components missing due to y position > 1

Hello, I have noticed when I open up an old matlab GUI (created using GUIDE) from back in 2015, some of the components are missing near the top of the figure.
I noticed that their y-position has somehow changed to be > 1 as shown below (1.16). Is there a way to correct & stop this?
n
Thanks
Jason

7 件のコメント

Adam Danz
Adam Danz 2019 年 1 月 10 日
What are the units? Are they normalized units?
Jason
Jason 2019 年 1 月 10 日
hi, yes they are normalised .
Adam Danz
Adam Danz 2019 年 1 月 10 日
If the GUI was created using guide, it would be easiest just to open the figure in guide, manually rearrange the GUI components, and then save the figure.
Jason
Jason 2019 年 1 月 10 日
hi.
Yes thats true, but as their noot visible and hence hard to dentify so i need to manually find tag and change their y position. its bit of a pain
Rik
Rik 2019 年 1 月 10 日
And some people still wonder why I'm so militant in my discouraging of the use of GUIDE.
You could try to fix this in code. At the end of the initializer you could loop through all children of the figure and set objects outside of the figure bounds to the required position.
Jason
Jason 2019 年 1 月 10 日
i wonder what causes them to have a normalised position > 1. Back in 2015 it was fine . All ive done is upgraded to the latest version of matlab and changed my pc (and screen)
Adam Danz
Adam Danz 2019 年 1 月 10 日
Before opening the hood, I'd open the GUI in matlab 2015 again (if possible) to confirm that this is a problem with the matlab version. I'd also confirm that the units are normalized. Sometimes merely closing and restarting matlab will fix these quirks. You mentioned that the screen was affected too which suggests a bigger problem.

サインインしてコメントする。

 採用された回答

Adam Danz
Adam Danz 2019 年 1 月 10 日

0 投票

This solution is based on Rik Wisselink's suggestion in the comments under the quesiton.
The idea is to find objects within the GUI whose positions are outside of the GUI frame. The code below should be run from within the GUI within any callback function or at the end of the initializer function and requires the 'handles' vector which is a structure listing all handles within the GUI.
handleVec = struct2array(handles); %handles is the handles structure
positions = get(handleVec, 'Position');
xPos = cellfun(@(x)x(1), positions);
yPos = cellfun(@(x)x(2), positions);
isout = xPos > 0.99 | yPos > 0.99;
handleVec(isout) %this lists all handles outside of the GUI frame
The next step depends on how many objects you have to move. If it's just a few, it might be best to just get the names of each object and then make the adjustments from within guide. If there are lots of objects, you'll need to manually place each of them from within the initializer function.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2019 年 1 月 10 日

コメント済み:

2019 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by