Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

CARTA DE SMITH EN MATLAB

function axes1_ButtonDownFcn(hObject, eventdata, handles)


function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)


function edit3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
global zore zoim zlre zlim ynorm zo zl x1 y1 tita
zore=str2double(get(handles.edit1,'string'))
zoim=str2double(get(handles.edit2,'string'))
zlre=str2double(get(handles.edit3,'string'))
zlim=str2double(get(handles.edit4,'string'))
zo=sqrt(zore^2+zoim^2)
zl=sqrt(zlre^2+zlim^2)
ynorm=zl/zo
if(zo==0)
else
t=0:0.1:2*pi;
x1=ynorm*cos(t);
y1=ynorm*sin(t);
plot(x1,y1,'linewidth',3)
xlim([-1 1])
ylim([-1 1])
end
tita=tan(atan(zlim/zlre)-atan(zoim/zore))

drawArrow = @(x,y,varargin) quiver(y(1),y(2),x(1),x(2),0,varargin{:})


x=[ynorm*sin(tita+pi/2) ynorm*cos(tita+pi/2)]
y=[0 0]

drawArrow(x,y,'linewidth',3,'color','k'); hold on
set(handles.text7,'string',ynorm)
set(handles.text8,'string',(pi/2+tita))
set(handles.edit8,'string',((1+ynorm)/(1-ynorm)))
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)

%Dibujamos nuestra circunferencia exterior


t=linspace(0,2*pi,100);
x=cos(t);
y=sin(t);
plot(x,y,'linewidth',3);axis equal;

%Ponemos el titulo
title('Carta de Smith')
set(gca,'xticklabel',{[]});
set(gca,'yticklabel',{[]});
hold on

%Dibujamos circunferencias a lo largo del eje horizontal


k=[.1 .2 .3 .4 .5 .6 .7 .8 .9 1 1.2 1.4 1.6 1.8 2 3 4 5 10 20 50];
for i=1 : length(k)
x(i,:)=k(i)+(1-k(i))*cos(t);
y(i,:)=(1-k(i))*sin(t);
plot(x(i,:), y(i,:), 'k')
end

%Dibujamos circunferencias a lo largo del eje vertical


kt=[-0 2 4 5 2.5 pi 3.79 4.22 ];
k=[.02 .05 .1 .2 .25 .33 .5 .55 .625 0.714 0.833 1 1.1 1.25 1.428 1.67 2
2.5 3.3 5 10];
for i=1 : length(k)
t=0:0.001:2*pi;
a(i,:)=1+k(i)*cos(t);
b(i,:)=k(i)+k(i)*sin(t);
plot(a(i,:), b(i,:), 'k', a(i,:), -b(i,:),'k')

end
r=-1:0.1:1
u=0*r
plot(r,u)
xlim([-1 1])
ylim([-1 1])
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
function edit4_Callback(hObject, eventdata, handles)
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit5_Callback(hObject, eventdata, handles)


function edit5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
function edit7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit8_Callback(hObject, eventdata, handles)


function edit8_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

%CARTA DE SMITH EN MATLAB


function draw_smith_chart
%Dibujamos nuestra circunferencia exterior
t=linspace(0,2*pi,100);
x=cos(t);
y=sin(t);
plot(x,y,'linewidth',3);axis equal;

%Ponemos el titulo
title('Carta de Smith')
set(gca,'xticklabel',{[]});
set(gca,'yticklabel',{[]});
hold on

%Dibujamos circunferencias a lo largo del eje horizontal


k=[.25 .5 .75];
for i=1 : length(k)
x(i,:)=k(i)+(1-k(i))*cos(t);
y(i,:)=(1-k(i))*sin(t);
plot(x(i,:), y(i,:), 'k')
end

%Dibujamos circunferencias a lo largo del eje vertical


kt=[2.5 pi 3.79 4.22];
k=[.5 1 2 4];
for i=1 : length(kt)
t=linspace(kt(i), 1.5*pi, 50);
a(i,:)=1+k(i)*cos(t);
b(i,:)=k(i)+k(i)*sin(t);
plot(a(i,:), b(i,:), 'k', a(i,:), -b(i,:),'k:')
end
%PARA EL CALCULO DEL COEFICIENTE DE REFLECCIÓN, RELACIÓN DE ONDA
%ESTACIONARIA DE VOLTAJE
function[m, thd, SWR, rloss]=smith_ch_calc(Z0, ZL)
%Dibujamos el cuadro apropiado
draw_smith_chart
%Normalizamos la impedancia dada
zl=ZL/Z0;
%Calculo de reflexión, magnitud y ángulo
cr=(zl-1)/(zl+1);
m=abs(cr);
th=angle(cr);
%grafico apropiado en un punto
polar(th, m, 'r*')
%Cambio de radianes a grados
thd=th*180/pi;
%Calculo de la relacion de onda estacionaria
%Añadimos épsilon a la magnitud para asi evitar la división entre cero
% y log(0)
SWR=(1+m)/(1-m+eps);
rloss=-20*log10(m+eps);

Ejecutando el programa insertamos en la ventana de comandos de Matlab lo siguiente:

Se realizo el trabajo en un entorno GUIDE en matlab.


Ejercicio.
Encontrar el coeficiente de relexion de una línea transmisión que
tiene un impedancia característica de z0=50 (ohm) Y una impedancia
de carga de ZL=25+25j (ohm),

You might also like