📄 smith.m
字号:
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function text5_CreateFcn(hObject, eventdata, handles)
% hObject handle to text5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function text6_CreateFcn(hObject, eventdata, handles)
% hObject handle to text6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushbutton3,'Enable','off');
set(handles.pushbutton10,'Enable','off');
set(gcf,'WindowButtonMotionFcn','');
zl = str2double(get(handles.edit1,'string'));
aida = (zl-1)/(zl+1);
abs_a = abs(aida);
b = 2*abs_a/sqrt(1-abs_a^2);
L1 = distance(0,j*1/b);
L2 = distance(0,-j*1/b);
d1 = distance(zl,1/(1+j*b));
d2 = distance(zl,1/(1-j*b));
set(handles.d1,'string',num2str(d1))
set(handles.d2,'string',num2str(d2))
set(handles.L1,'string',num2str(L1))
set(handles.L2,'string',num2str(L2))
guidata(hObject,handles)
r = real(zl);
x = imag(zl);
single_stub_match(r,x)
set(handles.pushbutton3,'Enable','on');
set(handles.pushbutton10,'Enable','on');
set(gcf,'WindowButtonMotionFcn',@draw);
hold off
function dis1_Callback(hObject, eventdata, handles)
% hObject handle to dis (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of dis as text
% str2double(get(hObject,'String')) returns contents of dis as a
% double
d1 = str2double(get(hObject,'String'));
if isnan(d1)
errordlg('You must input a number.');
set(handles.dis1, 'string', '');
elseif (d1<0)
errordlg('Distance cannot be negative.');
set(handles.dis1, 'string', '');
else
handles.current_d1 = d1;
guidata(hObject,handles)
end;
% --- Executes during object creation, after setting all properties.
function dis1_CreateFcn(hObject, eventdata, handles)
% hObject handle to dis (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
d = str2double(get(handles.dis,'String'));
zl = str2double(get(handles.edit1,'string'));
z = (zl+j*tan(2*pi*d))/(1+j*zl*tan(2*pi*d));
y = 1/z;
aida = (z-1)/(z+1);
set(handles.zin1,'string',num2str(z))
set(handles.yin1,'string',num2str(y))
set(handles.aida1,'string',num2str(aida))
% --- Executes on selection change in dis2.
function dis2_Callback(hObject, eventdata, handles)
% hObject handle to dis2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns dis2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from dis2
val = get(hObject,'Value');
str = get(hObject, 'String');
switch str{val};
case '1/8 λ'
handles.current_d2 = 0.125;
case '1/4 λ'
handles.current_d2 = 0.25;
case '3/8 λ'
handles.current_d2 = 0.375;
end
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function dis2_CreateFcn(hObject, eventdata, handles)
% hObject handle to dis2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function dis_Callback(hObject, eventdata, handles)
% hObject handle to dis (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of dis as text
% str2double(get(hObject,'String')) returns contents of dis as a double
d = str2double(get(hObject,'String'));
if isnan(d)
errordlg('You must input a number.');
set(handles.dis, 'string', '');
elseif (d<0)
errordlg('Distance cannot be negative.');
set(handles.dis, 'string', '');
end;
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pic2;
set(gcf,'WindowButtonMotionFcn','');
hold off;
subplot(pic2);
background;
hold on;
zl = str2double(get(handles.edit1,'string'));
gamma_yl=-(zl-1)/(zl+1)
r=abs(gamma_yl);
%这里是画弧的
t1=angle(gamma_yl)
d1 = handles.current_d1;
d2 = handles.current_d2;
yin = (1+j*zl*tan(2*pi*d1))/(zl+j*tan(2*pi*d1));
flag = 0; %标志是否盲区
switch d2;
case 0.125
if real(yin) >= 2
flag = 1;
errordlg('Blind Area!!!');
else
circle(0,0.5,0.5,'r','--');
end
case 0.25
if real(yin) >= 1
flag = 1;
errordlg('Blind Area!!!');
else
circle(-0.5,0,0.5,'r','--');
end
case 0.375
if real(yin) >= 2
flag = 1;
errordlg('Blind Area!!!');
else
circle(0,-0.5,0.5,'r','--');
end
end
if flag == 0
plot(real(gamma_yl),imag(gamma_yl),'kx', 'MarkerSize',10,'LineWidth',2);
hold on;
text(real(gamma_yl)+0.05,imag(gamma_yl),'zl');
gamma_y1=(yin-1)/(yin+1)
t2=angle(gamma_y1)
if t1<0
t1 = t1+2*pi;
end
if t2<0
t2 = t2+2*pi;
end
if t1>t2
t = t1:-0.01:t2;
else
t = t1:-0.01;-t2;
end
x=0+cos(t)*r;
y=0+sin(t)*r;
subplot(pic2);
plot(x,y,'r','LineWidth',2);
pause(0.5);
plot(x,y,'w','LineWidth',2);
pause(0.5);
plot(x,y,'r','LineWidth',2);
pause(0.5);
plot(x,y,'w','LineWidth',2);
pause(0.5);
plot(x,y,'r','LineWidth',2);
%后面的几个弧一样的,你只要看这里上面有什么问题就可以了
hold on;
plot(real(gamma_y1),imag(gamma_y1),'r>');
hold on;
g1 = real(yin);
syms x y g1_;
switch d2;
case 0.125
[x,y]=solve('(x-g1_/(1+g1_))^2+y^2 = 1/(1+g1_)^2' , 'x^2+(y-1/2)^2=1/4');theta=0.5*pi;
case 0.25
[x,y]=solve('(x-g1_/(1+g1_))^2+y^2 = 1/(1+g1_)^2' , '(x+1/2)^2+y^2=1/4');theta=pi;
case 0.375
[x,y]=solve('(x-g1_/(1+g1_))^2+y^2 = 1/(1+g1_)^2' , 'x^2+(y+1/2)^2=1/4');theta=1.5*pi;
end
x(1)=subs(x(1),g1_,g1);
x(2)=subs(x(2),g1_,g1);
y(1)=subs(y(1),g1_,g1);
y(2)=subs(y(2),g1_,g1);
x1=eval(x(1));
x2=eval(x(2));
y1=eval(y(1));
y2=eval(y(2)); %此处参考了师兄的程序SMITH1
aida(1) = x1+j*y1;
aida(2) = x2+j*y2;
yina(1) = (1+aida(1))/(1-aida(1));
yina(2) = (1+aida(2))/(1-aida(2));
r1=1/(1+real(yina(1)));
r2=1/(1+real(yina(2)));
t1=atan(y1/(x1-real(yina(1))/(real(yina(1))+1)));
t2=atan(y2/(x2-real(yina(2))/(real(yina(2))+1)));
t0=atan(imag(gamma_y1)/(real(gamma_y1)-real(yina(1))/(real(yina(1))+1)));
%以下是将幅角都转化为大于零小于2pi的角
if x1-real(yina(1))/(real(yina(1))+1) < 0 %第二,三象限
t1 = t1+pi;
end
if x2-real(yina(2))/(real(yina(2))+1) < 0
t2 = t2+pi;
end
if real(gamma_y1)-real(yina(1))/(real(yina(1))+1)
t0 = t0+pi;
end
if t1 < 0 %第四象限
t1 = t1+2*pi;
end
if t2 < 0
t2 = t2+2*pi;
end
if t0 < 0
t0 = t0+2*pi;
end
%一下决定弧的走向,使它沿较短的边画
if t1>t0
if t1-t0<pi
ta = t0:0.01:t1;
else
t1 = t1-2*pi;
ta = t1:0.01:t0;
end
else
if t0-t1<pi
ta = t1:0.01:t0;
else
t0 = t0-2*pi;
ta = t0:0.01:t1;
t0 = t0+2*pi;
end
end
if t2>t0
if t2-t0<pi
tb = t0:0.01:t2;
else
t2 = t2-2*pi;
tb = t2:0.01:t0;
end
else
if t0-t2<pi
tb = t2:0.01:t0;
else
t0 = t0-2*pi;
tb = t0:0.01:t2;
end
end
xa=real(yina(1))/(1+real(yina(1)))+cos(ta)*r1;
ya=0+sin(ta)*r1;
xb=real(yina(2))/(1+real(yina(2)))+cos(tb)*r2;
yb=0+sin(tb)*r2;
subplot(pic2);
plot(xa,ya,'b','LineWidth',2);
hold on;
plot(xb,yb,'b','LineWidth',2);
pause(0.5);
plot(xa,ya,'w','LineWidth',2);
plot(xb,yb,'w','LineWidth',2);
pause(0.5);
plot(xa,ya,'b','LineWidth',2);
hold on;
plot(xb,yb,'b','LineWidth',2);
pause(0.5);
plot(xa,ya,'w','LineWidth',2);
plot(xb,yb,'w','LineWidth',2);
pause(0.5);
plot(xa,ya,'b','LineWidth',2);
hold on;
plot(xb,yb,'b','LineWidth',2);
hold on;
plot(x1,y1,'b<');
hold on;
plot(x2,y2,'b<');
pause(1);
circle(0.5,0,0.5,'g','-');
tc=angle(aida(1));
td=angle(aida(2));
rc=abs(aida(1));
rd=abs(aida(2));
t3=tc:-0.01:(tc-theta);
t4=td:-0.01:(td-theta);
plot(rc*cos(t3),rc*sin(t3),'c','LineWidth',2);
plot(rd*cos(t4),rd*sin(t4),'c','LineWidth',2);
pause(0.5);
plot(rc*cos(t3),rc*sin(t3),'w','LineWidth',2);
plot(rd*cos(t4),rd*sin(t4),'w','LineWidth',2);
pause(0.5);
plot(rc*cos(t3),rc*sin(t3),'c','LineWidth',2);
plot(rd*cos(t4),rd*sin(t4),'c','LineWidth',2);
pause(0.5);
plot(rc*cos(t3),rc*sin(t3),'w','LineWidth',2);
plot(rd*cos(t4),rd*sin(t4),'w','LineWidth',2);
pause(0.5);
plot(rc*cos(t3),rc*sin(t3),'c','LineWidth',2);
plot(rd*cos(t4),rd*sin(t4),'c','LineWidth',2);
plot(rc*cos(tc-theta),rc*sin(tc-theta),'cp');
plot(rd*cos(td-theta),rd*sin(td-theta),'cp');
hold off;
b1(1) = yina(1)-yin;
L1(1) = distance(0,1/b1(1));
b1(2) = yina(2)-yin;
L1(2) = distance(0,1/b1(2));
yin3(1) = (yina(1)+j*tan(2*pi*d2))/(1+j*tan(2*pi*d2)*yina(1));
yin3(2) = (yina(2)+j*tan(2*pi*d2))/(1+j*tan(2*pi*d2)*yina(2));
b2(1) = -j*imag(yin3(1));
b2(2) = -j*imag(yin3(2));
L2(1) = distance(0,1/b2(1));
L2(2) = distance(0,1/b2(2));
set(handles.L1_1,'string',num2str(L1(1)))
set(handles.L1_2,'string',num2str(L1(2)))
set(handles.L2_1,'string',num2str(L2(1)))
set(handles.L2_2,'string',num2str(L2(2)))
guidata(hObject,handles)
end
set(gcf,'WindowButtonMotionFcn',@draw);
% --------------------------------------------------------------------
function uipanel12_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to uipanel12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global input;
if hObject == handles.zz
input = 'z';
else
input = 'y';
end
guidata(hObject,handles)
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
zl = str2double(get(handles.edit1,'string'));
aida = (zl-1)/(zl+1);
rou = (1+abs(aida))/(1-abs(aida));
angle_a = angle(aida);
if angle_a<0
angle_a = angle_a+2*pi;
end;
zmax = angle_a/4/pi;
if angle_a<pi
zmin = (angle_a+pi)/4/pi;
else
zmin = (angle_a-pi)/4/pi;
end;
set(handles.text5,'string',zmax)
set(handles.text6,'string',zmin)
set(handles.aida,'string',abs(aida))
set(handles.rou,'string',rou)
background;
hold on;
plot(real(aida),imag(aida),'x');
circle(0,0,abs(aida),'r','-');
circle(real(zl)/(1+real(zl)),0,1/(1+real(zl)),'g','-');
arch_x(imag(zl),'b');
hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -