Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Piecewise Function with Multiple Arguments

Please login with a confirmed email address before reporting spam

I would like to pass multiple arguments to a piecewise function, which I can't seem to do this directly (in Comsol 4.4). I can only pass one argument to a piecewise function, so I am trying to think of a work around. I'll give a simple example below, but I can give more specific info if desired.

For example, let's say I pass 3 variables/arguments (x,y,z) to a piecewise function named PW.
NOTE: x,y,z are not spatial coordinates.
I would like to set some variable (VAR) equal to PW(x,y,z).
PW would work as follows.
For the range 0<x<1 I want the function PW(x,y,z) = 2*y
For the range 1<x<2 I want the function PW(x,y,z) = 3*z
For the range 2<x<inf I want the function PW(x,y,z) = y + z

This is basically the same idea as an if/then statement.

Furthermore, I would really like to have the "functions" above be calls to other functions.
For example, again there are 3 variables/arguments (x,y,z).
For the range 0<x<1 I want the function PW(x,y,z) = g(x)
For the range 1<x<2 I want the function PW(x,y,z) = h(y)
For the range 2<x<inf I want the function PW(x,y,z) = j(y,z)
Where g(),h(), and j() are already defined analytical functions.
So, PW doesn't even actually have to use the arguments y and z, but does need to pass them on to other functions.

Any advice?
Thanks,
Bryan

0 Replies Last Post 2016年9月6日 GMT-4 19:29
COMSOL Moderator

Hello Bryan Burk

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.