Group Abstract Group Abstract

Message Boards Message Boards

0
|
5K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Plot3D calls function with non-numerical arguments

Posted 4 years ago

The plot of func works fine. The plot of func1 fails. The output of func1 shows that it has been called with nun-numerical values x and y, which func1 can't handle.

The documentation of Plot3D says "Plot3D has attribute HoldAll and evaluates f only after assigning specific numerical values to x and y."

func1 is a much-simplified version of what I am really working with, which I can't turn into a nice expression like x^2+y^2 <=1.

Attachments:
POSTED BY: David Golber
3 Replies
Posted 4 years ago

Thank you very much. That does it.

The Clear is necessary; I think: if one doesn't do the Clear, then Mathematica has TWO func1's defined, with different argument definitions. Then Plot3D chooses the first (wrong) one, which results in the error. Is this correct?

I still wish that the Mathematica documentation actually matched the actual behavior ... but then I have always been a a dreamer ...

POSTED BY: David Golber
Posted 4 years ago

Try

Clear[func1];
func1[x_?NumericQ,y_?NumericQ]:=...
POSTED BY: Bill Nelson
Posted 4 years ago

Rather than If and Return try using Piecewise to define the function.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard