www.gusucode.com > bioinfo 案例源码程序 matlab代码 > bioinfo/CreateBiographObjSpecifyAccessItsPropsExample.m

    %% Create a Biograph object and specify its properties 
% This example shows how to create a biograph object, access, and update
% its properties.

% Copyright 2015 The MathWorks, Inc.


%% 
% Create a biograph object with custom node IDs.
cm = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0];
ids = {'M30931','L07625','K03454','M27323','M15390'};
bg1 = biograph(cm,ids)
%%
% Specify the |ID| property of the object.
bg1.ID = 'mybg';
%% 
% Use the |get| function to display the node IDs.
get(bg1.nodes,'ID')
%%
% Display all properties and their current values of the 5th node
% and 5th edge of the object.
bg1.nodes(5)
%%
%
bg1.edges(5)
%%
% Set the |LineWidth| property of the 5th node to 2.
bg1.nodes(5).LineWidth = 2.0;
bg1.nodes(5)
%%
% Alternatively use |getnodesbyid| function to create a handle for the 5th
% node, and set its |Shape| property to 'circle'.
nh1 = getnodesbyid(bg1,'M15390')

%%
% 
nh1.Shape = 'circle';
%%
% Specify the |LineColor| property of the 5th edge.
bg1.edges(5).LineColor = [0.7 0.0 0.1];
%%
% Alternatively use |getedgesbynodeid| to retrieve the handel to the edge
% by providing a source node id and a sink node id.
eh1 = getedgesbynodeid(bg1,'L07625','M15390')
%%
% Use the handle to specify the |LineWidth| property or any other
% properties of the edge.
eh1.LineWidth = 2.0;
%%
% View the biograph object.
view(bg1)