⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prog_bar.m

📁 线性调频信号通过匹配滤波器的程序 还有一些simulink仿真模型
💻 M
字号:
function prog_bar(varargin)% Install this callback by invoking it with the command% prog_bar('init_block')% at the MATLAB prompt with the appropriate model file open and selected.%action = varargin{1}  ;switch action,  case 'init_block',    init_fcn ;                    % Block initialization function,                                  % located in this M-file  case 'create_fig',                  if(findobj('UserData',gcb))   % Don't open two for same block      disp('Only open one instance per block can be opened')    else      % Set up the figure and its callbacks      create_fig ;    end  case 'close_fig',               % Close if open when model is closed.    h_fig = findobj('UserData',gcb) ;    if(h_fig)                     % Is the figure for current block open?      close(h_fig) ;              % If so, close it.    end  case 'rename_block',            % Change the name in the figure UserData.    h_fig = findobj('UserData',gcb) ;    if(h_fig)                     % Is the figure open?      set(h_fig,'UserData',gcb) ; % If so, change the name.    end  case 'UpdateTime',               if(ishandle(varargin{2}))   % Only do update if block is open      do_update(varargin{2},varargin{3}) ;    endend%**********************************************************************%*                            init_fcn                                  *%**********************************************************************function init_fcn()% Configure the block callbacks% This function should be executed once when the block is created% to define the callbacks. After it is executed, save the model% and the callback definitions will be saved with the model. There is no need% to reinstall the callbacks when the block is copied; they are part of the% block once the model is saved.sys = gcs ;block = [sys,'/Progress'] ; set_param(block,'OpenFcn',      'prog_bar create_fig',...                'ModelCloseFcn','prog_bar close_fig', ...                'DeleteFcn',    'prog_bar close_fig', ...                'NameChangeFcn','prog_bar rename_block') ;set_param(gcb,'Tag','prog_bar') ;%**********************************************************************%*                            create_fig                                *%**********************************************************************function create_fig()% Create the progress bar figureh_fig = figure('Position',[200 200 200 30], ...               'MenuBar','none','NumberTitle','off', ...               'Resize','off', ...               'Name',[gcs,' Progress']) ;set(h_fig,'UserData',gcb) ; % Save name of current block in                            % the figure's UserData. This is                            % used to detect that a prog_bar fig                            % is already open for the current block,                            % so that only one instance of the figure                            % is open at a time.axis([0,1,0,1]) ;hold on ;h_axis = gca ;set(h_axis,'Xtick',[]) ;set(h_axis,'Ytick',[]) ;h_bar = fill([0,0.005,0.005,0],[0,0,1,1],'r') ; % Make the bar redStartTime = str2num(get_param(gcs,'StartTime')) ;StopTime  = str2num(get_param(gcs,'StopTime'))  ;set(h_bar,'UserData',[StartTime StopTime]) ; % Put the progress bar handle in the masked block data field% so that it can be passed to this function during the simulation.set_param(gcb,'MaskValueString',num2str(h_bar,25)) ;%**********************************************************************%*                            do_update                                *%**********************************************************************function do_update(h_bar,current_time)% Update the progress bar to the current simulation timeUserData = get(h_bar,'UserData') ;start_time = UserData(1) ;stop_time = UserData(2)  ;x_val = (current_time - start_time)/(stop_time - start_time) ;set(h_bar,'Xdata',[0,x_val,x_val,0]) ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -