简体   繁体   English

阶跃函数/重边函数MATLAB错误

[英]Step functions/Heaviside Functions MATLAB error

So im trying to plot f(t) which is a piecewise function using heaviside and ezplot functions in MATLAB. 所以我试图在MATLAB中使用heaviside和ezplot函数绘制f(t)这是一个分段函数。 Now im not very familiar with MATLAB at all. 现在我对MATLAB一点都不熟悉。 If anyone knows why im getting this error it would be helpful. 如果有人知道为什么我会收到此错误,它将很有帮助。

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

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

ezplot(f) ezplot(F)

Error using inlineeval (line 15) Error in inline expression ==> 12+(-2t+8).*heaviside(t-2)+(2t-12).*heaviside(t-6) Error: Unexpected MATLAB expression. 使用inlineeval的错误(第15行)内联表达式中的错误==> 12 +(-2t + 8)。* heaviside(t-2)+(2t-12)。* heaviside(t-6)错误:MATLAB表达式异常。

Error in inline/feval (line 34) INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr); 内联/插入错误(第34行)INLINE_OUT_ = inlineeval(INLINE_INPUTS_,INLINE_OBJ_.inputExpr,INLINE_OBJ_.expr);

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

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

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

You need to tell Matlab to multiply explicitly, use 2*t instead of 2t. 您需要告诉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])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM