Use more “natural” form to manipulate piecewise step functions in Matlab MuPAD?

我怕爱的太早我们不能终老 提交于 2019-12-24 14:53:14

问题


I have the unit step function:

u0:= piecewise([-infinity < t and t < 0,0],[0 < t and t < infinity,1]):

Now I want to plot it at some point:

T:=1:;
plot(u0|t=t-T/2);

This works. But when I use a more natural expression:

T:=1:;
plot(u0(t-T/2));

it simply plots the original unshifted step function.

Is there any way to use the more simpler form when plotting the modified step function?


回答1:


I believe the reason that what you call the "more natural form" doesn't work, is because u0 has not been defined as a MuPad function/procedure. In this case, you can create a procedure using the -> operator:

u0 := t -> piecewise([-infinity < t and t < 0, 0], [0 < t and t < infinity, 1]):

Note that the above is equivalent to u0 := t -> piecewise([t < 0, 0],[t > 0, 1]): (I assume that you're aware that you've left 0 undefined). Then you should be able to evaluate:

T := 1:
plot(u0(t-T/2))

Because u0 is now a function, your first form using the evalAt operator, |, must be altered to:

T := 1:
plot(u0(t)|t=t-T/2)


来源:https://stackoverflow.com/questions/27742672/use-more-natural-form-to-manipulate-piecewise-step-functions-in-matlab-mupad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!