Plot 倍频程不绘制函数

Plot 倍频程不绘制函数,plot,graph,octave,Plot,Graph,Octave,我正在准备一张结合蛋白质行为的图表 x = linspace(0,1,101) y = ( x.*2.2*(10^-4))/(( x.+6.25*(10^-2))*(x.+2.2*(10^-2))) plot(x,y) 结果应该是钟形曲线(也许)或曲线,但我得到的是线性图。我已经用其他软件检查过了,得到的曲线显示了该功能。有什么需要帮忙的吗?怎么了 您希望使用/数组除法,而不是/矩阵除法 如何调试这个 首先,在这里留出一些空间以便阅读。并添加分号以抑制较大的输出 x = linspace(0,

我正在准备一张结合蛋白质行为的图表

x = linspace(0,1,101)
y = ( x.*2.2*(10^-4))/(( x.+6.25*(10^-2))*(x.+2.2*(10^-2)))
plot(x,y)
结果应该是钟形曲线(也许)或曲线,但我得到的是线性图。我已经用其他软件检查过了,得到的曲线显示了该功能。有什么需要帮忙的吗?

怎么了 您希望使用
/
数组除法,而不是
/
矩阵除法

如何调试这个 首先,在这里留出一些空间以便阅读。并添加分号以抑制较大的输出

x = linspace(0, 1, 101);
y = (x.*2.2*(10^-4)) / ( ( x.+6.25*(10^-2)) * (x.+2.2*(10^-2)) );
plot(x, y)
然后将其粘贴到函数中以便于调试:

function my_plot_of_whatever
x = linspace(0, 1, 101);
y = (x.*2.2*(10^-4)) / ( ( x.+6.25*(10^-2)) * (x.+2.2*(10^-2)) );
plot(x, y)
现在试一试:

>> my_plot_of_whatever
error: my_plot_of_whatever: operator *: nonconformant arguments (op1 is 1x101, op2 is 1x101)
error: called from
    my_plot_of_whatever at line 3 column 3
当您收到关于
*
/
的类似投诉时,通常意味着您在执行矩阵运算,而实际上您需要元素级的“数组”运算
*
/
。请修复该问题,然后重试:

>> my_plot_of_whatever
>>

这是怎么回事?让我们使用调试器

>> dbstop in my_plot_of_whatever at 4
ans =  4
>> my_plot_of_whatever
stopped in /Users/janke/Documents/octave/my_plot_of_whatever.m at line 4
4: plot(x, y)
debug> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        x           1x101                      808  double
        y           1x1                          8  double
啊哈。您的
y
是标量,因此它对每个X值使用相同的y值。这是因为您使用的是
/
矩阵除法,而实际上您需要
/
数组除法。修正如下:

function my_plot_of_whatever
x = linspace(0, 1, 101);
y = (x.*2.2*(10^-4)) ./ ( ( x.+6.25*(10^-2)) .* (x.+2.2*(10^-2)) );
plot(x, y)
宾果


x.2.2(10^-4)的意思是什么?是x.*2.2(10^-4),但是编辑没有正确出现为什么不只是写
x.*2.2e-4
?“不一致的参数”。基本上你需要的是
*
而不是
*
@Adam,这样写的方式使得这样的错误很难发现。考虑写这更清楚,在几行,和适当的间距;然后,口译员会非常清楚地告诉您错误的确切位置。