zoomio.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 58 行

M
58
字号
% Function : zoom in or out of the graphic display of the signal to examine the GCI's.
%      Zoomio does zoom_in on the graph when Zio==1; the reverse if Zio=-1;
%      The zooming factor is specified by "zoom_zscale"
%
%      Zoomio.m is a call_function executed by "Zoom_in" and "Zoom_out" on the
%      figure(Gchek_f);

% 1. locate the region where we want to zoom in using the mouse

if Zio==1
   [str_p y]=ginput(1); % str_p is the current x coordinate of the mouse
   str_p=round(str_p);
elseif Zio==-1
   str_p=round( (left+right)/2 );
end

% 2. get the zoomimg factor
zscale=str2num(get(zoom_zscale,'String'));  % zscale == zooming scale

% 3. calculate the length of signal to plot
if exist('lethnow')==0
   lethnow=lens; % lethnow== the length of the signal displayed in the figure
end

if Zio == 1 % zoom in
	lethnow=round(lethnow/zscale);
        if lethnow>5000
           lethnow=5000; % show 5000 pts at most
        end
elseif Zio== -1 % zoom out
	lethnow=round(lethnow*zscale);
end;

% 4. Set the range, [left right], to display signal.

left= max([str_p-floor(lethnow/2) 1]);
if left == 1
	right= min([lethnow lens]);
else
	right= min([str_p+floor(lethnow/2) lens]);
end;
if right == lens
	left=max([1 lens-lethnow]);
end;

% 5. plot the signal with GCI

 % find GCIs between the margins
 idx=find(gci0>=left & gci0<=right);
 figure(Gchek_f);
 plot((left:right),signal(left:right),'b',gci0(idx),signal(gci0(idx)),'ko');

% set the shift-button on
set(shift_right,'Visible','on');
set(shift_left,'Visible','on');

clear str_p zscale;

⌨️ 快捷键说明

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