【问题标题】:Matlab , Error while plotting Heaviside. (Vectors must be the same length.)Matlab,绘制 Heaviside 时出错。 (向量的长度必须相同。)
【发布时间】:2016-05-17 22:37:54
【问题描述】:

我在 Matlab 中做一个汉明码问题。我生成了一个长度为 1190 的位串,用于传输。我被要求将字符串显示为阶跃函数曲线。

经过一番研究,我发现Heaviside函数可用于将位串显示为单位步长曲线。

当我使用命令fplot(heaviside(l_f),[0 ,10000]) 绘制曲线时,其中l_f 是长度为1190 的位串,我收到此错误

使用 fcnhk 时出错(第 106 行)

FUN 必须是函数、有效的字符串表达式或内联 函数对象。

fplot 中的错误(第 60 行) 乐趣 = fcnhk(乐趣);

无标题错误(第 88 行) fplot(heaviside(l_f),[0 ,10000])

当我使用 Plot 显示时,即 plot(heaviside(l_f),[0 ,10000]),我得到了错误

错误使用绘图向量的长度必须相同。

无标题(第 88 行)情节错误(heaviside(l_f),[0 ,10000])

无论如何要将位串绘制为阶跃函数曲线?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    fplot(heaviside(l_f),[0 ,10000]) 不会绘图,因为fplot 需要function 作为第一个参数。但在这里它是一个矩阵。所以请改用plot。接下来,heaviside(l_f) 的维度将为1x1190,[0 ,10000] 的维度为1x2。由于尺寸不同,因此无法使用。

    x=heaviside(l_f)
    y=0:(10000+1)/length(l_f):10000;
    plot(x,y);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多