📄 mytext1.m
字号:
function mytext1(ind) %,s1,s2,s3,s4,s5,s6)
%cla reset
%set(gca,'Box','on','XTick',[],'YTick',[],'Visible','off');
slideData=get(gcf,'Userdata');
doi=16;
%switch ind
% case doi+15
% s1='现在,需确定LPDF的参数:';
% s2='通带截止频率fp(Hz):';
% s3='通带最大衰减Rp(dB):';
% s4='阻带最低频率fs(Hz):';
% s5='阻带最小衰减Rs(dB):';
% s6='采样频率fsa(Hz):';
% case doi+16
% s1='现在,需确定HPDF的参数:';
% s2='通带下限频率fp(Hz):';
% s3='通带最大衰减Rp(dB):';
% s4='阻带上限频率fs(Hz):';
% s5='阻带最小衰减Rs(dB):';
% s6='采样频率fsa(Hz):';
% case doi+17
% s1='现在,需确定BPDF的参数:';
% s2='通带频率fp(Hz)=[fpl,fph]:';
% s3='通带最大衰减Rp(dB):';
% s4='阻带频率fs(Hz)=[fsl,fsh]:';
% s5='阻带最小衰减Rs(dB):';
% s6='采样频率fsa(Hz):';
%end;
%for i = 1:nargin-1
%disp('This is for mytext')
%disp(get(gca,'position'))
% eval(['text(0.01,' num2str(1.1-0.2*i) ',s' num2str(i) ...
% ',''FontUnits'',''points'',''FontSize'',' num2str(12) ');']);
%end
switch ind
case {doi+2,doi+3}
%axes('position',[0.25,0.55,0.3,0.2],'XTick',[0,pi/4,pi/2,pi]);
%w=0:pi/100:2*pi;
%Hw=ones(size(w));
%Hw(26:176)=0;
%plot(w,Hw);
%set(gca,'color',[0.8,0.8,0.8]);
delete(findobj('tag','doi+2/3'));
axes('position',[0.25,0.57,0.3,0.15]);
w=0:pi/500:2*pi;
Hw=ones(size(w));
Wsstr=get(slideData.BtnHandles(ind),'string');
Ws=LocalStrTrans(Wsstr);
WsNum=round(Ws/pi*500);
Hw(WsNum:1001-WsNum)=0;
% Title('理想低通频响');
Ws1=[0,Ws,2*pi-Ws,2*pi]; % Ws1 record the range whose value is 1
if (ind==doi+3)
Hw=1-Hw;
Ws1=[Ws,pi,pi,2*pi-Ws];
% Title('理想高通频响');
end
plot(w,Hw);
axis([0,2*pi,0,1]);
%axis off;
% set(gca,'color',[0.8,0.8,0.8],...
% 'XTick',[]);
if ind==doi+2
Title('理想低通频响');
else Title('理想高通频响');
end
xTckPos=[0,Ws,pi,2*pi-Ws,pi*2];%-[0.05,0.1,0.05,0.3,0.07];
set(gca,'XTick',xTckPos,...
'XTickLabel',{'0',Wsstr,'pi',strcat('2pi-',Wsstr),'2pi'},...
'Tag','doi+2/3');
save yhzfd Ws Ws1;
%XlblHnd=text(xTckPos,...
% -0.10*ones(1,5),{'0','Ws','\pi','2\pi-Ws','2\pi'});
% set(XlblHnd,'fontsize',11);
case doi+4
delete(findobj('tag','doi+4'));
axes('position',[0.15,0.57,0.45,0.15]);
w=0:pi/500:2*pi;
Hw=zeros(size(w));
Wsstr=get(slideData.BtnHandles(doi+4),'string');
Ws=LocalStrTrans(Wsstr);
WsNum=round(Ws/pi*500);
Hw(WsNum(1):WsNum(2))=1;
Hw(1001-WsNum(2):1001-WsNum(1))=1;
Ws1=[Ws(1),Ws(2),2*pi-Ws(2),2*pi-Ws(1)];
plot(w,Hw);
set(gca,'XTick',[],'Xlim',[0,2*pi]);
Title('理想带通频响');
xTicPos=[0,Ws(1),Ws(2),pi,pi*2]; %-...
% [0.05,0.1,0.2,0.05,0.4,0.4,0.07];
%XlblHnd=text(xTicPos,-0.1*ones(1,7),...
% {'0','Wsl','Wsh','\pi','2\pi-Wsh','2\pi-Wsl','2\pi'});
%set(XlblHnd,'fontsize',9);
set(gca,'XTick',xTicPos,'XTickLabel',{'0','Wsl','Wsh','pi','2pi'},'tag','doi+4');
save yhzfd Ws Ws1
case doi+5
j=1;
while ~get(slideData.BtnHandles(2,j),'value')
j=j+1;
end
% switch j
% case 1
Wsstr=get(slideData.BtnHandles(doi+1+j),'string');
% transfer the string to caculable digits
% for i=1:length(Wsstr)-1
% if (Wsstr(i:i+1)=='pi')& (Wsstr(i-1)~='*')
% Wsstr=strcat(Wsstr(1:i-1),'*',Wsstr(i:length(Wsstr)));
% end
% end
% Ws=str2num(Wsstr);
Ws=LocalStrTrans(Wsstr);
Wsnor=Ws/pi;
hi=LocalPlotHi(50,Wsnor,j);
% switch j
% case 1
% hi=firls(50,[0,Wsnor,Wsnor,1],[1,1,0,0]);
% case 2
% hi=firls(50,[0,Wsnor,Wsnor,1],[0,0,1,1]);
% case 3
% hi=firls(50,[0,Wsnor(1),Wsnor(1),Wsnor(2),Wsnor(2),1],...
% [0,0,1,1,0,0]);
% end %switch j
%disp(length(hi));
axes('position',[0.15,0.57,0.6,0.28]);
yhzstem(hi);
hold on;
plot(zeros(size(hi)));
%axis([1,51,-0.1,0.3]);
set(gca,'Xlim',[1,51]);
set(gca,'XTick',[26],'XTickLabel','0');
Xlabel('n');
yLabel('hi(n)');
filType=j;
clear doi j i ind Wsstr hi slideData
save yhzfd
% save Ws, Wsnor, filType
%end %switch j
case doi+6
currentBtn=findobj('visible','on','style','radiobutton','value',1);
winTypeS=get(currentBtn,'string');
ls_strtmp=''; winType='boxcar';
for li_row=1:size(winTypeS,1),
ls_strtmp=char(winTypeS(li_row,:));
if ~isempty(findstr(ls_strtmp,'窗')), break; end;
end;
if ~isempty(findstr(ls_strtmp,'Rectangular')) winType='boxcar'; end;
if ~isempty(findstr(ls_strtmp,'Hanning')) winType='hanning'; end;
if ~isempty(findstr(ls_strtmp,'Hamming')) winType='hamming'; end;
if ~isempty(findstr(ls_strtmp,'Blackman')) winType='blackman'; end;
if ~isempty(findstr(ls_strtmp,'Kaiser')) winType='kaiser'; end;
%'save yhzfd winType',
winplot(gcf,winType),
clear winType currentBtn;
clear winTypeS ls_strtmp li_row;
case doi+7
%mytext1(21,'');
delete(findobj('Tag','slide23Axes'));
load yhzfd
winLenM=str2num(get(slideData.BtnHandles(doi+7),'string'));
winLenN=2*winLenM+1;
% yhzfd: Ws, Wsnor, filType, winStyle,and possibly: winLenM,winLenN,win
if strcmp(winStyle,'kaiser')
win=eval([winStyle '(' num2str(winLenN) ',' betaS ')']);
else
win=eval([winStyle '(' num2str(winLenN) ')']);
end
% plot the time domain response
%save yhzfd winStyle;
axes('position',[0.15,0.57,0.6,0.18]);
%yhzstem(b);
nExt=3;
yhzstem([zeros(nExt,1);win;zeros(nExt,1)]);
oPos=(winLenN+2*nExt+1)/2;
set(gca,...
'Xlim',[1,winLenN+2*nExt],...
'XTick',[oPos-winLenM,oPos,oPos+winLenM],...
'XTickLabel',{strcat('-',num2str(winLenM)),'0',num2str(winLenM)},...
'Tag','slide23Axes');
%save winStyle;
clear doi ind nExt oPos i slideData
save yhzfd %winStyle winLenM winLenN win Ws Wsnor filType
case doi+8
load yhzfd
% yhzfd:=7 varibles winStyle, winLenM, winLenN, win, Ws, Wsnor, filType
hi=LocalPlotHi(winLenN-1,Wsnor,filType);
axes('position',[0.15,0.57,0.6,0.18]);
nExt=3;
winN=[zeros(1,nExt),win',zeros(1,nExt)];
hiN=[zeros(1,nExt),hi,zeros(1,nExt)];
%N=[1:size(winN)];
yhzstem(winN','c:');
hold on;
yhzstem(hiN');
hold on;
plot(zeros(size(winN)));
set(gca,...
'Xlim',[1,winLenN+2*nExt],...
'XTick',[nExt+1,nExt+winLenM+1,nExt+winLenN],...
'XTickLabel',{'1',strcat('M+1=',num2str(winLenM+1)),strcat('N=',num2str(winLenN))});
clear doi ind nExt N slideData
save yhzfd %winStyle winLenM winLenN win Ws Wsnor filType hi winN hiN
case doi+9
load yhzfd
% yhzfd: winStyle winLenM winLenN win Ws Wsnor filType hi winN hiN
h=win'.*hi;
hN=winN.*hiN;
[w,f]=freqz(h/sum(h),1,1024);
nExt=3;
XTickLabel1={'1',strcat('M+1=',num2str(winLenM+1)),strcat('N=',num2str(winLenN))};
LocalResult(hN',[1,winLenN+2*nExt],[nExt+1,nExt+winLenM+1,nExt+winLenN],XTickLabel1,w,f,Wsnor,winLenN,1);
% plot the time domain response
% axes('position',[0.1,0.57,0.6,0.28]);
% yhzstem(hN');
% hold on;
% plot(zeros(size(hN')));
% nExt=3;
% set(gca,...%'color',[0.8,0.8,0.8],...
% 'Xlim',[1,winLenN+2*nExt],...
% 'XTick',[nExt+1,nExt+winLenM+1,nExt+winLenN],...
% 'XTickLabel',{'1',strcat('M+1=',num2str(winLenM+1)),strcat('N=',num2str(winLenN))});
% plot the frequency domain response
% [w,f]=freqz(h/sum(h),1,1024);
% axes('position',[0.1,0.17,0.3,0.28]);
% semilogy(f,(abs(w)));
% WsstrT=strcat(num2str(Wsnor'),'pi');
% [M,N]=size(WsstrT);
% if M==1
% Wsstr={'0',WsstrT,'pi'};
%else
% Wsstr={'0',WsstrT(1,:),WsstrT(2,:),'pi'};
% end;
% set(gca,....%'color',[0.8,0.8,0.8],...
% 'Xlim',[0,pi],...
% 'XTick',[0,Wsnor*pi,pi],...
% 'XTickLabel',Wsstr);
%plot the phase response
% XLabel('幅频响应');
%axes('position',[0.45,0.17,0.27,0.28]);
%plot(f,angle(w));%unwrap(angle(w)));
%set(gca,...%'color',[0.8,0.8,0.8],...
% 'Xlim',[0,4*pi/(winLenN-1)],...
% 'XTick',[0,4*pi/(winLenN-1)],...%Wsnor*pi,pi],...
% 'XTickLabel',{'0','4pi/(N-1)'},...
% 'Ylim',[-pi,pi],...
% 'YTick',[-pi,-pi/2,0,pi/2,pi],...
% 'YTickLabel',{'-pi','-pi/2','0','pi/2','pi'});
%XLabel('相频响应');
% Prepare the data transfered to the yhzfdview, which is used to analysis the result
label=get(gcf,'name');
bz=h;
az=1;
WsstrT=strcat(num2str(Wsnor'),'pi');
[MM,NN]=size(WsstrT);
if MM~=1
WsstrT=[WsstrT(1,:),' ',WsstrT(2,:)];
end;
paraLabel={['窗口:',winStyle];['长度:',num2str(length(h))];['截止频率:',WsstrT]};
%paraLabel=char(paraLabel);
clear doi ind slideData nExt w f XTickLabel1 WsstrT MM NN
%clear WsstrT Wsstr
save yhzfd;
% yhzfd: winStyle winLenM winLenN win Ws Wsnor filType hi winN hiN h hN label bz az paraLabel
case doi+10
set(slideData.BtnHandles(doi+10,1:4),'Enable','on');
j=1;
while ~get(slideData.BtnHandles(2,j),'value')
j=j+1;
end
if j==1
set(slideData.BtnHandles(doi+10,3:4),'Enable','off');
% if get(slideData.BtnHandles(doi+10,3),'value')| get(slideData.BtnHandles(doi+10,4),'value')
% set(slideDataData.BtnHandles(doi+10,1),'value',1
elseif j==2
set(slideData.BtnHandles(doi+10,2:3),'Enable','off');
end
enoffBtns=findobj('Enable','off','value',1);
if ~isempty(enoffBtns)
set(slideData.BtnHandles(doi+10,1),'value',1);
set(enoffBtns,'value',0);
end
case doi+11
%load yhzfd;
% Ws
MStr=get(slideData.BtnHandles(doi+11),'string');
j=1;
while ~get(slideData.BtnHandles(26,j),'value')
j=j+1;
end
set(gcf,'currentaxes',slideData.axesHandle(1));
if (j==1)|(j==3)
text(0.01,0.7,'N=2*M+1, M=');
N=str2num(MStr)*2+1;
else
text(0.01,0.7,'N=2*M, M=');
N=str2num(MStr)*2;
end
delete(findobj('tag','N='));
text(0.01,0.5,strcat('N=',num2str(N)),'tag','N=');
j=1;
while ~get(slideData.BtnHandles(2,j),'value')
j=j+1;
end
jIndex=doi+1+j;
mytext1(jIndex);
load yhzfd;
% yhzfd: Ws Ws1
hold on;
% N=str2num(MStr);
wN=(2*pi/N)*[0:N];
yhzstem(wN,ones(size(wN)),'y:');
clear doi ind slideData j jIndex MStr wN
save yhzfd ;
% save N Ws Ws1
case doi+12
axes('position',[0.15,0.57,0.6,0.28]);
load yhzfd;
% yhzfd: N Ws Ws1
for i=1:N
wN=(2*pi/N)*(i-1);
if ((wN>=Ws1(1)) & (wN<=Ws1(2))) | ((wN>=Ws1(3)) & (wN<=Ws1(4)))
HK(i)=1;
else HK(i)=0;
end % if
end %for
HK(N+1)=HK(1);
%r=1000/N;
%HwN=resample(Hw,N,1000);
yhzstem(HK);
set(gca,'Xlim',[1,N+1],'XTick',[1,N+1],'XTickLabel',{'0',strcat('N=',num2str(N))});
clear i wN doi ind slideData
save yhzfd
% save yhzfd: HK N Ws Ws1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -