Ask Your Question
1

3d plot ignoring imaginary part

asked 13 years ago

Michele gravatar image

Is there any possibility to have a 3d plot done in a way that if the expression to be plotted returns a complex number, this is not plotted. In particular I'm referring to this feature in Matlab: when you try to plot in 3d an expression which in his domain has both real and complex values, it returns the plot only when the values are real. In addition Matlab prints a Warning: "Imaginary parts of complex X, Y, and/or Z arguments ignored".

Thanks! (tell me if it's not clear, I'll explain better...)

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 13 years ago

Michele gravatar image

I just get to a solution by myself... My problem was the impossibility to plot because of numerical errors that turns my (expected) real values into complex numbers with an imaginary part extremely small.

I used the fantastic function "list_plot3d". For example:

var ('x y')
f = sqrt(1+x+y)
list = []
for n in [-2.0,-1.9..,2.]:
    for m in [-2.0,-1.9..,2.]:
        list.append((n,m,real(f(x=n,y=m))))
show(list_plot3d(list))

It's not difficult to modify the above code if one wants to really ignore complex numbers while plotting (that is indeed what Matlab automatically does).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 1,119 times

Last updated: Mar 09 '12