From: Emanuele Steiz on
Hi everyone,

Im a rookie MatLab user and i have a question about how to set bounds to functions and how to "merge" functions together:
What i need to do is a function composed by 3 linear functions, for example:

y1 = x from -5 to 5
y2 = x/2 +5/2 from 5 to 10
y3 = x/2 -5/2 from -10 to -5

what i have been able to do since now is:

syms x
y1=x
y2=x/2 +5/2
y3=x/2 -5/2

now how can i set min and max bounds to these 3 functions and how can i add one to each other to obtain a unique function?

Thanks for any answer
From: Torsten Hennig on
> Hi everyone,
>
> Im a rookie MatLab user and i have a question about
> how to set bounds to functions and how to "merge"
> functions together:
> What i need to do is a function composed by 3 linear
> functions, for example:
>
> y1 = x from -5 to 5
> y2 = x/2 +5/2 from 5 to 10
> y3 = x/2 -5/2 from -10 to -5
>
> what i have been able to do since now is:
>
> syms x
> y1=x
> y2=x/2 +5/2
> y3=x/2 -5/2
>
> now how can i set min and max bounds to these 3
> functions and how can i add one to each other to
> obtain a unique function?
>
> Thanks for any answer

http://www.mathworks.com/matlabcentral/fileexchange/9394-piecewise-functions

Best wishes
Torsten.