【问题标题】:Step functions/Heaviside Functions MATLAB error阶跃函数/Heaviside Functions MATLAB 错误
【发布时间】:2014-04-04 01:22:37
【问题描述】:

所以我试图在 MATLAB 中使用 heaviside 和 ezplot 函数绘制一个分段函数 f(t)。现在我对 MATLAB 一点也不熟悉。如果有人知道我为什么会收到此错误,那将会很有帮助。

f = '12+(-2t+8)*heaviside(t-2)+(2t-12)*heaviside(t-6)'

f = 12+(-2t+8)*heaviside(t-2)+(2t-12)*heaviside(t-6)

ezplot(f)

使用 inlineeval 时出错(第 15 行)内联表达式出错 ==> 12+(-2t+8).*heaviside(t-2)+(2t-12).*heaviside(t-6) 错误:意外MATLAB 表达式。

inline/feval 中的错误(第 34 行) INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

ezplotfeval 中的错误(第 52 行) z = feval(f,x(1));

ezplot 中的错误>ezplot1(第 469 行) [y, f, loopflag] = ezplotfeval(f, x);

ezplot 中的错误(第 145 行) [hp, cax] = ezplot1(cax, f{1}, vars, labels, args{:});

【问题讨论】:

    标签: matlab function inline piecewise


    【解决方案1】:

    您需要告诉 Matlab 显式乘法,使用 2*t 而不是 2t。

    syms t real
    f = 12+(-2*t+8)*heaviside(t-2)+(2*t-12)*heaviside(t-6)
    ezplot(f,[0 10])
    

    【讨论】:

      猜你喜欢
      • 2020-11-03
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 2018-04-24
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 2015-10-27
      相关资源
      最近更新 更多