0

所以我试图在 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{:});

4

1 回答 1

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])
于 2014-04-04T01:33:00.737 回答