1004 1

MATLAB课程:代码示例之Graphics and Visualization(五) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.5582
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399203 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-8 15:07:16 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Graphics and Visualization(五)

Programmatically Create a User Interface with Tabbed Panels


This example shows how to create a user interface with tab panels in MATLAB®.


Objects Used to Create Tab Panels

The tabgroup and tab objects are used to build user interfaces with tab panels. A tabgroup object is created using the uitabgroup function. A tab object is created using the uitabfunction with a tabgroup as its parent. The tab objects appear in the order in which they are created.

f = figure;tgroup = uitabgroup('Parent', f);tab1 = uitab('Parent', tgroup, 'Title', 'Loan Data');tab2 = uitab('Parent', tgroup, 'Title', 'Amortization Table');tab3 = uitab('Parent', tgroup, 'Title', 'Principal/Interest Plot');


Like all graphics objects, tabgroups and tabs have properties that you can view and modify. These properties have default values. The display of a tabgroup or a tab shows its most commonly used properties.

tgroup


tgroup =   TabGroup with properties:            SelectedTab: [1x1 Tab]    SelectionChangedFcn: ''            TabLocation: 'top'               Position: [0 0 1 1]                  Units: 'normalized'  Use GET to show all properties


tab1


tab1 =   Tab (Loan Data) with properties:              Title: 'Loan Data'    BackgroundColor: [0.9400 0.9400 0.9400]           Position: [0.0036 0.0071 0.9911 0.9357]              Units: 'normalized'  Use GET to show all properties


Get Individual Tabgroup and Tab Properties

To access individual properties, use the dot notation syntax object.Property. For example, return the TabLocation property of the tabgroup.

tgroup.TabLocation


ans =top


Change Tabgroup and Tab Properties

To customize the look of a tabgroup or tab object, change any property value using the dot notation syntax object.Property.

tab3.ForegroundColor = 'blue';tgroup.SelectedTab = tab1;


Add Components to Tab

Tabs contain user interface components such as labels, buttons, and edit boxes. To add a component to a tab, create the component and set its parent to the tab.

lblLoanAmount = uicontrol('Parent', tab1, 'Style', 'text', 'String', 'Loan Amount', ...  'HorizontalAlignment', 'left', 'Position', [80 320 170 25]) ;edtLoanAmount = uicontrol('Parent', tab1, 'Style', 'edit', ... 'Position', [224 320 200 30]) ;


Create a Callback

The tabgroup object has one callback called SelectionChangedFcn. This callback function is called when the user changes the currently selected tab.

tgroup.SelectionChangedFcn = @tabChangedCB;


For example, if you want the application to recalculate the amortization table and update the plot when the user leaves the "Loan Data" tab, then set the SelectionChangeCallback to a function with this format:

function tabChangedCB(src, eventdata)
% Get the Title of the previous tabtabName = eventdata.OldValue.Title;
% If 'Loan Data' was the previous tab, update the table and plotif strcmp(tabName, 'Loan Data')   % <insert code here to update the amortization table and plot>end
end
Get All Tabgroup and Tab Properties

Graphics objects in MATLAB have many properties. To see all the properties of a tabgroup or tab object, use the get command.

get(tgroup)


           BeingDeleted: 'off'             BusyAction: 'queue'          ButtonDownFcn: ''               Children: [3x1 Tab]              CreateFcn: ''              DeleteFcn: ''       HandleVisibility: 'on'          Interruptible: 'on'                 Parent: [1x1 Figure]               Position: [0 0 1 1]            SelectedTab: [1x1 Tab]    SelectionChangedFcn: @tabChangedCB         SizeChangedFcn: ''            TabLocation: 'top'                    Tag: ''                   Type: 'uitabgroup'          UIContextMenu: [0x0 GraphicsPlaceholder]                  Units: 'normalized'               UserData: []                Visible: 'on'


get(tab3)


     BackgroundColor: [0.9400 0.9400 0.9400]        BeingDeleted: 'off'          BusyAction: 'queue'       ButtonDownFcn: ''            Children: [0x0 GraphicsPlaceholder]           CreateFcn: ''           DeleteFcn: ''     ForegroundColor: [0 0 1]    HandleVisibility: 'on'       Interruptible: 'on'              Parent: [1x1 TabGroup]            Position: [0.0036 0.0071 0.9911 0.9357]      SizeChangedFcn: ''                 Tag: ''               Title: 'Principal/Interest Plot'       TooltipString: ''                Type: 'uitab'       UIContextMenu: [0x0 GraphicsPlaceholder]               Units: 'normalized'            UserData: []



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB课程 Graphics GRAPHIC MATLAB Visual MATLAB课程 代码示例 GraphicsandVisualization ProgrammaticallyCreateaUserInterfacewithTabbedPanels


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

沙发
我愿一生孤独 在职认证  发表于 2016-3-8 15:09:00
好样的,受教了。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 19:44