How to put a figure window in the center of the screen?

조회 수: 167 (최근 30일)
Merse Gaspar
Merse Gaspar 2023년 5월 27일
댓글: Merse Gaspar 2023년 5월 28일
Is it possible to put a figure (for example a GUI window) in the center of the screen? How to get screen size in pixels, or how to measure position not from the bottom, but from the top?

채택된 답변

Atsushi Ueno
Atsushi Ueno 2023년 5월 27일
width = 640; height = 480;
Pix_SS = get(0,'screensize')
Pix_SS = 1×4
1 1 1920 1200
[(Pix_SS(3)-width)/2 (Pix_SS(4)-height)/2 width height]
ans = 1×4
640 360 640 480
figure('Position', [(Pix_SS(3)-width)/2 (Pix_SS(4)-height)/2 width height])
  댓글 수: 3
Walter Roberson
Walter Roberson 2023년 5월 27일
Historically, 0 was used to refer to the "root" of the handle graphics system -- the object that is the parent of all figures (and other figure-like graphics objects.)
These days, using groot is the preferred way to refer to the root of the graphics system. (There are a small number of differences between using 0 and using groot() that most people would never notice)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Adam Danz
Adam Danz 2023년 5월 27일
> Is it possible to put a figure (for example a GUI window) in the center of the screen? |
movegui('center')
or
movegui(fig,'center')
where fig is a figure handle.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by