Multiplication of non-zero symbolic functions yields zero answer
Show older comments
I want to multiply two symbolic functions. However at the point of multiplying the functions I do not know which combination of the two variables are variable for each of the functions (findSymType(f,'variable') can be either empty, [t1], [t2], or [t1 t2] and the same applies to g).
The code below shows what I want to do.
syms f(t1,t2) g(t1,t2)
assume(t1, 'real')
assume(t2, 'real')
f(t1, t2) = piecewise(t1 <= 2, 1/2, 0)
g(t1, t2) = piecewise(t2 < 1, 1/2 - t2/2, 1 <= t2, 0)
a=f*g
res1 = a(0.5, 0.5)
res2 = f(0.5, 0.5) * g(0.5, 0.5)
When I multiply the two symbolic functions to yield a new symbolic function 'a', I unexpetedly yield 0. I also checked this answer by computing the value of the function for values of t1 and t2 that should yield a non-zero example. Specifically I would want res1 to yield the value of res2 (1/8) and a to yield something like:
a(t1,t2)=piecewise(t1 <= 2 & t2 < 1, 1/4-t2/4, 0)
How do I get 'a' to yield this answer?
I'll be thankful for any help!
Accepted Answer
More Answers (0)
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



