简体   繁体   中英

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

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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