フィルターのクリア

Resizing my figure table

2 ビュー (過去 30 日間)
Tan
Tan 2021 年 8 月 27 日
回答済み: Chunru 2021 年 8 月 27 日
Hi, I would like to ask how can I make my "PUSH" Buttons change their position when I enlarge my figure.
Currently my "PUSH" Buttons have the positions specified, and when i maximise the figure, my subplotted axes will change in position but the push buttons remain the same.
Thank you!
function []=plotting_8_figures()
S.fh = figure('units','pixels',...
'position',[350 100 1200 1000],...
'menubar','none',...
'numbertitle','off',...
'name','8 Figures axes',...
'resize','on');
for n=1:8
subplot(4,2,n)
end
S.pb(1) = uicontrol('style','push',...
'units','pixels',...
'position',[450 820 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(2) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 820 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(3) = uicontrol('style','push',...
'units','pixels',...
'position',[450 600 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(4) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 600 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(5) = uicontrol('style','push',...
'units','pixels',...
'position',[450 380 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(6) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 380 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(7) = uicontrol('style','push',...
'units','pixels',...
'position',[450 160 120 30],...
'fontsize',10,...
'string',['PUSH']);
S.pb(8) = uicontrol('style','push',...
'units','pixels',...
'position',[1000 160 120 30],...
'fontsize',10,...
'string',['PUSH']);
set(S.pb(:),{'callback'},{{@pb1_call,S};{@pb2_call,S};{@pb3_call,S};{@pb4_call,S}...
;{@pb5_call,S};{@pb6_call,S};{@pb7_call,S};{@pb8_call,S}});
function [] = pb1_call(varargin)
close(S.fh)
end
function [] = pb2_call(varargin)
close(S.fh)
end
function [] = pb3_call(varargin)
close(S.fh)
end
function [] = pb4_call(varargin)
close(S.fh)
end
function [] = pb5_call(varargin)
close(S.fh)
end
function [] = pb6_call(varargin)
close(S.fh)
end
function [] = pb7_call(varargin)
close(S.fh)
end
function [] = pb8_call(varargin)
close(S.fh)
end
end

採用された回答

Chunru
Chunru 2021 年 8 月 27 日
A simple approach is to use normalized units for specifying position:
S.pb(1) = uicontrol('style','push',...
'units','normalized',...
'position',[0.2 0.4 0.2 0.1],... % adjust these values
'fontsize',10,...
'string',['PUSH']);
A more complicated approach is to use the callback function SizeChangedFcn.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by