简体   繁体   中英

MATLAB- Renaming issue of heaviside.m

1) int(( heaviside(sym('t')) ),0,0.5 ) works perfectly but when I edit the in-built MATLAB file heaviside.m and rename it as my_heaviside.m and then call it in the command window as
int(( my_heaviside(sym('t')) ),0,0.5 ) it shows error.

2) How to write the following piecewise function with the help of heaviside: f(x)= 1, 2<=x <3 & 0 elsewhere. Note that at x=2 , I require f(x)= 1 and at x=3 , I require f(x)= 0 .

3) I want that the f(x) in point no. 2 should be defined in such a way that it can be symbolically integrate like in point 1.

您应该尝试将my_heaviside.m文件中的函数名称从heaviside更改为my_heaviside。

If you use a breakpoint in the heaviside function, then you will see that Matlab never actually goes into the function when evaluating heaviside(t) . Why? What should be the output of heaviside(t) ? It is supposed to be heaviside(t) ! What it actually does is it goes to the method heaviside inside of the sym class definition, the output of that function is just mupadmex('symobj::map',ts,'heaviside') which is just another name for the heaviside of t (here s is a private property of a sym object).

Also when Matlab tries to integrate the heaviside function, it cannot integrate it from first principles by looking at the structure of the mfile , but it uses theorems to evaluate expressions containing it; thus one cannot hope to edit the actual mupad file for heaviside and expect Matlab to find the correct integral.

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