0% found this document useful (0 votes)
44 views7 pages

'Value' 'Value' 'Value' 'Value' 'Value' 'Value': % Graficas de Circulo

The document contains code for calculating and plotting impedance values on a Smith Chart. It defines variables for input impedance values, calculates the normalized impedance, reflection coefficient and other parameters. Based on checkbox values, it will either plot the circles and lines for the Smith Chart or show the specific location and lines for the normalized impedance values.

Uploaded by

luis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views7 pages

'Value' 'Value' 'Value' 'Value' 'Value' 'Value': % Graficas de Circulo

The document contains code for calculating and plotting impedance values on a Smith Chart. It defines variables for input impedance values, calculates the normalized impedance, reflection coefficient and other parameters. Based on checkbox values, it will either plot the circles and lines for the Smith Chart or show the specific location and lines for the normalized impedance values.

Uploaded by

luis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

A=(get(app.

lEditField,'value'))
F=(get(app.FEditField,'value'))
Zlreal=(get(app.ZlrealEditField,'value'))
Zlima=(get(app.ZlimaEditField,'value'))
Zoreal=(get(app.ZorealEditField,'value'))
Zoima=(get(app.ZoimaEditField,'value'))
Zl=Zlreal+j*Zlima
Zo=Zoreal+j*Zoima
C=3*10^8
Y=(C/F)
L=A*Y
B=((2*pi)/Y)
gama=(Zl-Zo)/(Zl+Zo)
vswr=(1+abs(gama))/(1-abs(gama))
Zin=Zo*((Zl+j*Zo*tan(B*L))/(Zo+j*Zl*tan(B*L)))
set(app.zinrealEditField,'value',real(Zin))
set(app.zinimaEditField,'value',imag(Zin))
set(app.gamarealEditField,'value',real(gama))
set(app.gamaimaEditField,'value',imag(gama))
set(app.maggamaEditField,'value',abs(gama))
set(app.vswrEditField,'value',vswr)
Zlreal = (get(app.ZlrealEditField,'value'));
Zlima = (get(app.ZlimaEditField, 'value'));

Zl = Zlreal + j * Zlima;

Zoreal = (get(app.ZorealEditField,'value'));
Zoima = (get(app.ZoimaEditField, 'value'));

Zo = Zoreal + j * Zoima;

ZlRealN = Zlreal / Zoreal;


ZlImagN = Zlima / Zoreal;

% GRAFICAS DE CIRCULO
hr=ZlRealN./(1+ZlRealN);
rr=1./(1+ZlRealN);

[x,y1,y2] = circ([hr,0],rr)
plot(app.UIAxes,x,y1,'--g','linewidth',0.7);
plot(app.UIAxes,x,y2,'--g','linewidth',0.7);

ki=1./(ZlImagN);
ri=1./(ZlImagN);

[x,y1,y2] = circ([1,ki],ri)
plot(app.UIAxes,x,y1,'--g','linewidth',0.7);
plot(app.UIAxes,x,y2,'--g','linewidth',0.7);
% HACIENDO LINEA
gamma = (Zl - Zo) ./ (Zl + Zo);

gReal = real(gamma);
gImag = imag(gamma);

m = gImag ./ gReal;

x = [0,1];
y = [0,m];

plot(app.UIAxes,x,y,'g','linewidth',0.7);

% HALLAR EL ANGULO

alpha = atan(m);
alpha = alpha * 180 / 3.1416;
beta = 180 - alpha;

set(app.AlphaEditField,'value',alpha)

% HALLAR LAMDA INICIAL

frec = (get(app.FEditField,'value'));
n = (3*10^8 ./ frec);
ni = (( beta * n ./ 4 ) ./ 180);

set(app.ninicialEditField,'value',ni)

% HALLAR ZIN (SIN NORMALIZAR)

l = (get(app.lEditField,'value'));
B = (2 * 3.1416) ./ n;

g = tan(B*l);
g = g * 180 / 3.1416;

num1 = Zl + j * Zo * g;
num2 = Zo + j * Zl * g;

Zin = Zo * (num1 ./ num2);

ZinR = real(Zin);
ZinI = imag(Zin);

set(app.zinrealEditField,'value',ZinR)
set(app.zinimaEditField,'value',ZinI)

function [x,y1,y2] = circ (c,r)


h = c(1);
k = c(2);
x = h-r : 2*r / 200 : h+r;
y1 = sqrt (r^2 - (x-h).^2)+k;
y2 = -sqrt (r^2 - (x-h).^2)+k;

end
end
% Value changed function: cartadesmithCheckBox
function cartadesmithCheckBoxValueChanged(app, event)
value = app.cartadesmithCheckBox.Value;

if(value==1)
app.UIAxes

%---------------
cont = 10;

rl = [0:0.01:0.2, 0.22:0.02:0.5, 0.55:0.05:1, 1:0.1:2,2.2:0.2:5,


6:10, 12:2:20, 30, 40, 50];
xl = [0:0.01:0.2, 0.22:0.02:0.5, 0.55:0.05:1, 1:0.1:2,2.2:0.2:5,
6:10, 12:2:20, 30, 40, 50];

hr = rl./(1+rl);
rr = 1 ./(1+rl);
%kr = zeros(1,length(rl));

%hi = 1;
ki = 1./ xl;
ri = 1./ xl;
%---------------

for i=1 : length(rl)

[x,y1,y2] = circ([hr(i),0],rr(i)); % Parte real


plot(app.UIAxes, x,y1,'b','linewidth',0.01);
plot(app.UIAxes, x,y2,'b','linewidth',0.01);

[x,y1,y2] = circ([1, ki(i)],ri(i)); % Parte imaginaria superior


plot(app.UIAxes, x,y1,'b','linewidth',0.01);
plot(app.UIAxes, x,y2,'b','linewidth',0.01);

[x,y1,y2] = circ([1,-ki(i)],ri(i)); % Parte imaginaria inferior


plot(app.UIAxes, x,y1,'b','linewidth',0.01);
plot(app.UIAxes, x,y2,'b','linewidth',0.01);

end

xlim(app.UIAxes,[-1 1])
ylim(app.UIAxes,[ -1 1])

% CIRCULO DE IMPEDANCIA ZL
% [x,y1,y2] = circ([zlRealN/2,0],zlRealN/2,'r');
% plot(x,y1,'r','linewidth',1);
% plot(x,y2,'r','linewidth',1);
% hold on

% FORMACION DE PATRON
for i = 20 : cont : 80

if i == 20
cont = 15;
end

if i == 35
cont = 10;
end

if i == 55
cont = 15;
end

[x,y1,y2] = circ([hr(i), 0],rr(i));


plot(app.UIAxes, x,y1,'r','linewidth',0.3);
plot(app.UIAxes, x,y2,'r','linewidth',0.3);

[x,y1,y2] = circ([1, ki(i)],ri(i));


plot(app.UIAxes, x,y1,'r','linewidth',0.3);
plot(app.UIAxes, x,y2,'r','linewidth',0.3);

[x,y1,y2] = circ([1, -ki(i)],ri(i));


plot(app.UIAxes, x,y1,'r','linewidth',0.3);
plot(app.UIAxes, x,y2,'r','linewidth',0.3);

end

end

function [x,y1,y2] = circ (c,r)


h = c(1);
k = c(2);
x = h-r : 2*r / 200 : h+r;
y1 = sqrt (r^2 - (x-h).^2)+k;
y2 = -sqrt (r^2 - (x-h).^2)+k;
% plot (x,y1,color)
% xlim([-1,1])
% ylim([-1,1])
% hold on
%
% plot(x,y2,color)
end
end
% Value changed function: dbCheckBox
function dbCheckBoxValueChanged(app, event)
value = app.dbCheckBox.Value;
A=(get(app.lEditField,'value'))
F=(get(app.FEditField,'value'))
Zlreal=(get(app.ZlrealEditField,'value'))
Zlima=(get(app.ZlimaEditField,'value'))
Zoreal=(get(app.ZorealEditField,'value'))
Zoima=(get(app.ZoimaEditField,'value'))
Zl=Zlreal+j*Zlima
Zo=Zoreal+j*Zoima
C=3*10^8
Y=(C/F)
L=A*Y
B=((2*pi)/Y)
gama=(Zl-Zo)/(Zl+Zo)
vswr=(1+abs(gama))/(1-abs(gama))
Zin=Zo*((Zl+j*Zo*tan(B*L))/(Zo+j*Zl*tan(B*L)))
if(value==0)

set(app.maggamaEditField,'value',abs(gama))
set(app.vswrEditField,'value',vswr)

else

b=get(app.maggamaEditField,'value')
c=get(app.vswrEditField,'value')
z=10*log10(b)
e=20*log10(c)
set(app.maggamaEditField,'value',z)
set(app.vswrEditField,'value',e)

end
end
% Value changed function: solucioncartaCheckBox
function solucioncartaCheckBoxValueChanged(app, event)
value = app.solucioncartaCheckBox.Value;
Zlreal=(get(app.ZlrealEditField,'value'))
Zlima=(get(app.ZlimaEditField,'value'))
Zoreal=(get(app.ZorealEditField,'value'))
Zoima=(get(app.ZoimaEditField,'value'))
Zl=Zlreal+j*Zlima
Zo=Zoreal+j*Zoima
znormalizado=(Zl/Zo)
% parte real e imaginaria de zl normalizada
a=real(znormalizado)
h=imag(znormalizado)
gama=(Zl-Zo)/(Zl+Zo)

% vector

rl=[0:0.01:0.2,0.22:0.02:0.5,0.55:0.05:1,1.1:0.1:2,2.2:0.2:5,6:10,12:2:20,30
,40,50]
% real
hr=rl./(1+rl)
rr=1./(1+rl)
% imag positiva
cx1=ones(length(rl),1)'
cy1=1./rl
rx1=1./rl
% imag negativa
cx2=ones(length(rl),1)'
cy2=-1./rl
rx2=1./rl

if(value==1)

for ii=1:length(rl)
if (rl(ii)==a)
znr=ii
[x,y1,y2]=circuloeje([hr(znr),0],rr(znr),'r')
plot(app.UIAxes,x,y1,'k')
plot(app.UIAxes,x,y2,'k')
end
end

if(h>0)
for bb=1:length(rl)
if (rl(bb)==h)
znr1=bb

[x,y1,y2]=circuloeje([1,cy1(znr1)],rx1(znr1),'k')
plot(app.UIAxes,x,y1,'k')
plot(app.UIAxes,x,y2,'k')
end
end
end
if(h<0)
for bb=1:length(rl)
if (-rl(bb)==h)
znr2=bb

[x,y1,y2]=circuloeje([1,cy2(znr2)],rx2(znr2),'b')
plot(app.UIAxes,x,y1,'k')
plot(app.UIAxes,x,y2,'k')
end

end
end

[x,y1,y2]=circuloeje([hr(46),0],set(app.maggamaEditField,'value',abs(gama)),
'r')
plot(app.UIAxes,x,y1,'k')
plot(app.UIAxes,x,y2,'k')

end

You might also like