Message Boards Message Boards

0
|
21175 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How do you make a piecewise function of two variables and plot it?

Posted 11 years ago
I am having difficulties defining the function f(x,y)=1 for 4<x<6, 4<y<6 and 0 Otherwise.
Here is what I have been trying:
f[x, y] = Piecewise[{{1, {{4 < x < 6}, {4 < y < 6}}}, {0, else}}]
This does not seem to work as when I plot it by doing:
Plot3D[{f[x,y]}, {x, 0, 10}, {y, 0, 10}]
nothing comes up.

Does anyone know how this can be done?

Thank you very much!
POSTED BY: Nicholas Yevcak
2 Replies
f[x_, y_] := Piecewise[{{1, 4 < x < 6  && 4 < y < 6}, {0, True}}]

Plot3D[f[x,y],{x,0,10},{y,0,10}]
I am presuming you mean that x should be between 4 and 6 AND y should be between 4 and 6 rather than x should be between 4 and 6 OR y should be between  4 and 6

You might find the documentation page , http://reference.wolfram.com/mathematica/ref/Piecewise.html, useful.
Posted 11 years ago
That is exactly what I needed! Thank you very much!
POSTED BY: Nicholas Yevcak
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract