2

我正在使用 Octave 绘制一个简单的方程,但它返回一个像这样的空图 ,代码如下:

# Computing of Zin
# Constants
RL=50;
L=1;
mu=4e-7*pi;
eps=1;
nu=3e8/sqrt(eps);
s=50;
r=7.5;
l=(mu/pi)*log((s-r)^2/r^2);
c=1/(l*nu^2);
R0=sqrt(l/c);
beta=2*pi*sqrt(l*c);

# Equation
Zin=R0*(RL+R0*tan(beta*f)*1i)/(R0+RL*tan(beta*f)*1i);
printf("l=%e ; c=%e ; R0=%f ; beta=%e\n",l,c,R0,beta);
printf("Zin(f) = %f for f = %d Hz.\n",Zin,f);

# Plot Zin(f)
f=logspace(7,11);
figure(1);
semilogx(f,Zin);
title('Zin(f)');

八度返回这个:

l=1.387681e-006 ; c=8.006964e-012 ; R0=416.304253 ; beta=2.094395e-008
Zin(f) = 444.026370 for f = 10000000 Hz.
Zin(f) = 12067926.406393 for f = 14563484 Hz.
Zin(f) = 17575106.248548 for f = 21209508 Hz.
Zin(f) = 25595479.226995 for f = 30888435 Hz.
Zin(f) = 37275937.203149 for f = 44984326 Hz.
Zin(f) = 54286754.393239 for f = 65512855 Hz.
Zin(f) = 79060432.109077 for f = 95409547 Hz.
Zin(f) = 115139539.932645 for f = 138949549 Hz.
Zin(f) = 167683293.681101 for f = 202358964 Hz.
Zin(f) = 244205309.454865 for f = 294705170 Hz.
Zin(f) = 355648030.622312 for f = 429193426 Hz.
Zin(f) = 517947467.923120 for f = 625055192 Hz.
Zin(f) = 754312006.335461 for f = 910298177 Hz.
Zin(f) = 1098541141.987557 for f = 1325711365 Hz.
Zin(f) = 1599858719.606057 for f = 1930697728 Hz.
Zin(f) = 2329951810.515372 for f = 2811768698 Hz.
Zin(f) = 3393221771.895329 for f = 4094915062 Hz.
Zin(f) = 4941713361.323838 for f = 5963623317 Hz.
Zin(f) = 7196856730.011529 for f = 8685113738 Hz.
Zin(f) = 10481131341.546831 for f = 12648552169 Hz.
Zin(f) = 15264179671.752302 for f = 18420699693 Hz.
Zin(f) = 22229964825.261909 for f = 26826957953 Hz.
Zin(f) = 32374575428.176399 for f = 39069399371 Hz.
Zin(f) = 47148663634.573898 for f = 56898660290 Hz.
Zin(f) = 68664884500.429985 for f = 82864277285 Hz.
Zin(f) = 100000000000.000000 for f = 

我不明白这个问题。我也试图让它成为一个用 fplot 绘制它的函数,但没有成功。

在此先感谢您的帮助。

4

1 回答 1

0

请更改代码

semilogx(f,Zin);

semilogx(f,Zin, '*');

然后检查输出,其中点显示为“*”。

更新:

这是代码:

function zin
    RL=50;
    L=1;
    mu=4e-7*pi;
    eps=1;
    nu=3e8/sqrt(eps);
    s=50;
    r=7.5;
    l=(mu/pi)*log((s-r)^2/r^2);
    c=1/(l*nu^2);
    R0=sqrt(l/c);
    beta=2*pi*sqrt(l*c);
    f=logspace(7,11);

    # Equation
    printf("l=%e ; c=%e ; R0=%f ; beta=%e\n",l,c,R0,beta);

    Zin = R0*(RL+R0*tan(beta*f)*1i)./(R0+RL*tan(beta*f)*1i);

    # Plot Zin(f)


    size(Zin)


    semilogx(f,Zin,'r-x');

    title('Zin(f)');

end

图像显示在

于 2012-10-31T06:33:31.380 回答