www.pudn.com > communicationmatlab.rar > STDINIT.M


function stdinit 
%STDINIT is a function for SIMULINK STD block which opens a STD edit figure. 
%   STDINIT is called by doubel click the STD block in SIMULINK. 
% 
%   See Also STDEXCUT 
 
%   Author: Wes Wang start 12-20-93 
%       Copyright (c) 1995-96 by The MathWorks, Inc.% 
 
[sys, block] = get_param; 
[n_b, m_b]= size(blocks); 
if n_b ~= 1 
     error('std may be called from SIMULINK STD block only') 
end; 
sys = [sys '/' block]; 
fig_name = sys; 
 
block = find(sys == setstr(10)); 
for i = ind 
     fig_name(i) = '_'; 
end; 
 
% Find out if the figrue exist. If exist, make it to be current.  
% Otherwise, create a new figrue for editing. 
Figures = get(0,'Child'); 
new_fig = 1; 
L_fig = length(Figures); 
i = 1; 
while ((new_fig) & (i <= L_fig)) 
 if strcmp(get(Figures(i), 'Type'), 'figure') 
            if strcmp(get(Figures(i), 'Name'), fig_name) 
            sto_name = num2str(get(fig_name,'UserData')); 
            if strcmp(sto_name, fig_name) 
                          h_fig = Figures(i); 
                set(0,'CurrentF',h_fig); 
                new_fig = 0; 
            end; 
        end; 
    end; 
    i = i + 1; 
end; 
 
if new_fig 
    %get the paramter of how many input/output/state, logic representation 
    %output representation and output name 
    %get u-dim, y-dim, s-dim, s-transf-map, output-map, output-name 
    [u,y,s,tf,yo,yn] = stdgetpm(sys); 
 
    %open a new figure 
    h_fig = figure('Unit','ixel','Pos',[100,100, 400, 300],... 
            'Name',fig_name); 
    set(0,'CurrentF',h_fig); 
    h_axis = axes('Visible','off'); 
    set(h_fig,'UserData',[h_axis, u, y, s]); 
     
    stdfresh(h_fig, u, y, s, tf, yo, yn);     
end;