|
From: Hans-Bernhard B. <HBB...@t-...> - 2010-10-05 13:37:28
|
On 04.10.2010 21:47, Federico Bergero wrote: > Hi I'm trying to plot a discontinuous function like this > > f(x) = a1*x**2+b1*x+c1 for x in [t11,t12] > f(x) = a2*x**2+b2*x+c2 for x in [t21,t22] > f(x) = a3*x**2+b3*x+c3 for x in [t31,t32] > .... > .... > ... > where t11<=t12<=t21<=t22, etc > > and I don't know how to do it. Several ways possible. You could combine all functions into one using the ? operator: f(x) = (x < t21) ? f1(x) : (x < t31) ? f2(x) : f3(x) Or you can plot each function individually, like you appear to be doing now. > I've tried defining as many functions as intervals and making the > function undefined (1/0) outside its interval and plotting each > function (with persistent plot) Using multiplot for that is wrong. Just plot f1(x), f2(x), f3(x) > but it doesn't work when the intervals > are small. So up the 'set samples'. Better yet, switch to parametric mode, map a common t interval [0:1] to your individual t ranges, and then: x1(t) = t11+t*(t12-t11) ... plot x1(t), f1(x1(t)), x2(t), f2(x2(t)), ... |