For Programmers: Free Programming Magazines  


Home > Archive > Mathematica > August 2006 > General--IF condition in Plot3D









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author General--IF condition in Plot3D
madhukarrapaka@yahoo.com

2006-08-26, 4:02 am

Hi All,

How to use a IF condition in Plot3D??

For example:
I have "I" values caluclated by I=P/2*Pi*r*L .; where P=10.3,L=0.45,r=dist.
So if i want to plot "I" when "r<x", how to do it??
(Here i am giving my procedure thru which i am getting a Plot with some warning)
r[x_,y_]:=Sqrt[x^2+y^2];
I[x_,y_]:=P/2*Pi*r[x_,y_]*L
Plot3D[If[r[x,y]<=0.082,I[x,y]],{x,-0.082,0.082},{y,-0.082,0.082}]

Then i am getting following warnings:
1. Plot3D::"plnc" :
If[(r[x, y]<=0.82),I[x, y] is neither a machine-size real number at {x,y}=(-0.058,-0.082) nor a list of a real number and a valid color directive.

2. General::"stop": Further output of Plot3D :: plnc will be suppressed during this calculation.

3. Plot3D::"gval": Function value (Null) at grid point xi = 1, yi = 1 is not a real number.

4. General::"stop": "Further output of Plot3D :: gval will be suppressed during this calculation."

Is there anything wrong in the syntax or range specification.
I am clueless. Please provide me ur valueable suggestions.

Thanks in advance.



Thanks in advance

Link to the forum page for this post:
http://www.mathematica-users.org/we...id=12975#p12975
Posted through http://www.mathematica-users.org [[postId=12975]]


Jean-Marc Gulliet

2006-08-26, 4:03 am

madhukarrapaka@yahoo.com wrote:
> How to use a IF condition in Plot3D??
>
> For example:
> I have "I" values caluclated by I=P/2*Pi*r*L .; where P=10.3,L=0.45,r=dist.
> So if i want to plot "I" when "r<x", how to do it??
> (Here i am giving my procedure thru which i am getting a Plot with some warning)
> r[x_,y_]:=Sqrt[x^2+y^2];
> I[x_,y_]:=P/2*Pi*r[x_,y_]*L
> Plot3D[If[r[x,y]<=0.082,I[x,y]],{x,-0.082,0.082},{y,-0.082,0.082}]
> [...]
> Is there anything wrong in the syntax or range specification.


The following works:

r[x_, y_] := Sqrt[x^2 + y^2];
i[x_, y_] := (P/2)*Pi*r[x, y]*L
Plot3D[Boole[r[x, y] <= 0.082]*i[x, y] /.
{P -> 10.3, L -> 0.45}, {x, -0.082, 0.082},
{y, -0.082, 0.082}];

HTH,
Jean-Marc

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com