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


    function    [xx] = sviplot1(input); 
 
%This function is only used by Call back MATLAB from C-mex funcitons sviterbi.c  
%  Copyright (c) 1996 The MathWorks, Inc. 
%  All Rights Reserved 
% See also sviplot1, sviplot2, sviplot3 
 
    x(1) = input(1); 
    n_std_sta = input(2); 
    num_state = input(3); 
    plot_flag = input(4); 
    initial_flag = input(5); 
 
  if x(1) <= 0    
    % initialize the figure. 
    [sl_name, block] = get_param; 
    [n_b, m_b]= size(block); 
    if n_b < 1 
        error('Cannot delete block while simulating') 
    elseif n_b > 1 
        error('Something wrong in get_param, You don''t have the current SIMULINK') 
    end; 
 
    % findout if the graphics window exist 
    ind = find(sl_name == setstr(10)); 
    dash = '_'; 
    sl_name(ind)=dash(ones(size(ind))); 
 
    % in the case of the figure exists 
    Figures = get(0, 'Child'); 
    new_figure = 1; 
    i = 1; 
    while ((new_figure) & (i <= length(Figures))) 
        if strcmp(get(Figures(i), 'Type'), 'figure') 
            if strcmp(get(Figures(i), 'Name'), sl_name) 
                h_fig = Figures(i); 
                handles = get(h_fig,'UserData'); 
                new_figure = 0; 
                h_axis = handles(1); 
                set(0,'CurrentF',h_fig); 
                set(h_axis,'Xlim', [0, plot_flag-1], 'Ylim', [0, n_std_sta-1]); 
                delete(get(h_axis,'child')); 
                handles = handles(1); 
            end; 
        end; 
        i = i + 1; 
    end; 
    if new_figure 
        h_fig = figure; 
        set(h_fig, 'Name', sl_name); 
        handles = axes('Xlim',[0, plot_flag-1], 'Ylim',[0, n_std_sta-1]); 
    end; 
    handles = get(h_fig, 'Child'); 
    set(handles, 'Visible', 'Off'); 
    set(handles(1),'NextPlot','add'); 
    set(h_fig,'NextPlot','add', 'Clipping', 'off'); 
    handles(2) = plot(0,0,'y-','Erasemode','normal'); 
    handles(3) = plot(0,0,'r-','Erasemode','normal','LineWidth',2); 
    handles(4) = plot(-10,-10, 'go', 'Erasemode','normal'); 
    for i = 1 : n_std_sta 
        handles(i+4) = text(0,0,'0'); 
        set(handles(i+4), 'Color',[0,1 1]); 
    end; 
    for i = 0 : n_std_sta - 1 
        handles(5+n_std_sta+i) = text(-plot_flag/8, i, ['State ', num2str(bi2de(fliplr(de2bi(i, num_state))))]); 
    end; 
    handles(5+2*n_std_sta) = text(plot_flag/2.1, - n_std_sta/15, 'Time'); 
    set(h_fig, 'UserData',handles); 
    set(h_axis,'NextPlot','new'); 
    set(h_fig,'NextPlot','new'); 
    sys(1) = h_fig; 
    x(1) = h_fig; 
  end;% if x(1) < 0 
 
  plot_flag_test = get(0,'child'); 
 
  if isempty(plot_flag_test) 
    plot_flag_test = 0; 
  elseif isempty(find(plot_flag_test==x(1))) 
    plot_flag_test = 0; 
  else 
    plot_flag_test = 1; 
    handles = get(x(1), 'UserData'); 
    if length(handles) ~= (5+2*n_std_sta) 
        plot_flag_test = 0; 
    end; 
  end; 
 
xx(1) = x(1); 
xx(2) = plot_flag_test; 
xx(3) = 12345; 
%%%%% end plot1 related %%%%%