问题
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