Ask Your Question
1

3d plot ignoring imaginary part

asked 2012-03-07 12:33:08 +0100

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...)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-03-09 10:48:57 +0100

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).

edit flag offensive delete link more

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: 2012-03-07 12:33:08 +0100

Seen: 1,057 times

Last updated: Mar 09 '12