Matlab / Octave:无法绘制方程式

时间:2012-10-31 06:02:49

标签: plot octave

我正在使用Octave绘制一个简单的等式,但它返回一个空的图,如this  这是代码:

# 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)');

Octave返回:

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绘制它的功能,但是没有成功。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

请更改代码

  

semilogx(F,寻);

  

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

图片显示在this