Code covered by the BSD License  

Highlights from
Ezimplot3: implicit 3D functions plotter

4.6

4.6 | 6 ratings Rate this file 50 Downloads (last 30 days) File Size: 3.75 KB File ID: #23623
image thumbnail

Ezimplot3: implicit 3D functions plotter

by Gustavo Morales

 

10 Apr 2009 (Updated 07 Oct 2010)

Plots a 3D surface defined implicitly

| Watch this File

File Information
Description

At last Matlab do it!!!
Useful tool to plot a 3D implicit surface defined in cartesian coordinates. You can give f(x,y,z) = 0 as a string or as a function handle. Type <help ezimplot3> for usage. Remember to leave your comments and ratings...Thanks!

;)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
implot.m

Required Products Symbolic Math Toolbox
MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (24)
29 Jul 2009 Tamara Kolda

This is fantastic! Just what I was looking for and what ezplot3 should do!

One questions/suggestion: Is there a way to also choose the color of the surface that's plotted? I was able to do it manually using the get/set commands, but I was hoping to be able to do it using the function directly.

Thanks for sharing this with the community.

01 Aug 2009 Gustavo Morales

I'd like to study ezgraph3 throughly to make -ezimplot3- a "real command", and maybe some day, Mathworks could take it ;)
And...There's a way.... try writing:
>>help ezimplot3
for usage

25 Aug 2009 Dave Yap

Dear Gustavo, really nice and neat program.
I would like to plot a DeJong1 test function as below,
f1(x)=sum(x(i)^2), i=1:n, -5.12<=x(i)<=5.12

I'm unable to plot the Dejong1 test function.
Could you pls help me on this?
my email is dyfw@hotmail.com. Thanks in advance.

31 Aug 2009 Gustavo Morales

Dave, as you should know, you only can see plots for explicit R2 to R functions, so the index "i" must be at most 2. Your function is also known as "Parabola", and has this other explicit (not implicit) form:
                  f(x,y) = x^2 + y^2 ... a paraboloid
I suggest that use instead the following command:

>> plotobjective(@dejong1fcn,[-5.12 5.12;-5.12 5.12]);

;-)

22 Oct 2009 Brian Bak

Hi

Does anyone no why I can't plot the following:

f = '(x/(400^2 - 0.3*y))^2 + (z/(400^2 - 0.3 *y))^2 -1';
ezimplot3(f,[-3000 3000 -10000 10000 -3000 3000])

It just shows an empty plot from 0 to 1 on all axes. And gives the output: ans = 0.0037

thanks in advance

22 Oct 2009 Brian Bak

My mistake it was just the boundaries that where wrong.

22 Oct 2009 Gustavo Morales

the numeric answer you get is a handle for the patch object

22 Oct 2009 Gustavo Morales

I didn't understand you... so... have you already discovered the mistake? I was trying to do something about it, and that's what I've found:
> f = '(x/(4 - 3*y))^2 + (z/(4 - 3 *y))^2 -1';
> ezimplot3(f,[-3000 3000 -10000 10000 -3000 3000]);

It produces a nice graph... maybe the function that you provided is too small...
Regards!

22 Oct 2009 Brian Bak

Hi Gustavo Morales

Just as you wrote the boundaries was not large enough for the surfaces to be plottet.

Do you have any suggestions to how you kan change the surface to be a grid instead of a color?

Thanks in advance.

Very nice program btw!

22 Oct 2009 Gustavo Morales

Hi!
> h = ezimplot3() outputs a handle for the patch object. So you can do the folowing:
> set(h,'FaceColor','none','EdgeColor','k')

I hope I have been able to help you.
"I prefer being useful than being important"

23 Feb 2010 Hisham Moideen

hi Gustavo,

I have an implicit function, but the variables are alpha, gamma and R.
Can i use ezimplot3() to output my function?

Also is it possible to input different range for my variables like
ezimplot3(M1,[0.2 6 0 5 0 0.34]), will that work?

Appreciate the help and code.

24 Feb 2010 Gustavo Morales

Hi...
*fun can be a string, an anonymous function handle, a .M-file handle, an inline function or a symbolic function. Any other variable present at the function (aside from alpha, gamma and R), must have a known value, that is, your function must depend only of alpha, gamma and R.
*>> domain = [min-alpha max-alpha min-gamma max-gamma min-R max-R];
ezimplot3(fun,domain);

test with the examples of help: >> help ezimplot3

regards from Venezuela!

24 Feb 2010 Hisham Moideen

hi Gustavo,
I tried plotting the way you suggested.

h1=ezimplot3(M1,[0.02 5 0 4 0 0.35]);

where M1 is the determinant of a matrix involving the three variables alpha,gamma,R.

I got the following error:
"??? Error using ==> ezimplot3 at 82
FUN must have no more than 3 arguments"

To make sure i dont have more than 3 unknowns, i substituted specific values for each and got a single value for my Function M1.

Is is possible that i could send you my code of generating M1 and maybe you could help me.

Problem is my function M1 is not a simple function. Its a determinant of a matrix of order 8. Some of the terms in my matrix is polynomial fit of alpha and R. So the determinant is one crazy looking expression. Matlab cant output my entire determinant value (out of line limit error).

Appreciate any help in this regard!!!

01 Mar 2010 Gustavo Morales

Hi Hisham.. ok! send me the code of M1 by email...

16 Apr 2010 Camilla Colombo

Dear Gustavo,

thank you for your function. I am trying to plot an implicit function coded into an m. file. However i get an error and i think this is due to the fact that my function contains some "if condition". So I get the error at line 168 of ezimplot3:
f_sym = eval([fun,'(x,y,z)']); % evaluating FUN at the sym point (x,y,z)

do you know a way to avoid this problem?

thank you in advance

Camilla

02 May 2010 Gustavo Morales

Hi Camilla!
Your funcion has others arguments than x,y,z?
Can you send me the code of your function?... Send it by email...

12 May 2010 Camilla Colombo

Hi Gustavo,

I sent you an email to gmorales@uc.edu.ve
Please let me know if you received it.

Thanks
Camilla

21 May 2010 Gustavo Morales

Hi Camilla!!! I've already aswered your email...!

23 Jul 2010 Michelle Gledhill

Hello Gustavo,
Is there a way to add a contour plot on the x-y-plane in a similar way that the function "surfc" does?
Thank you for your time!

06 Oct 2010 Jonathan

This seems like a good function. However, I could not discover it since my time has been fruitlessly spent. This function requires the symbolic toolbox, yet no mention of this was explicitly included on this page or in the function help.

07 Oct 2010 Gustavo Morales

Sorry for not being a good software documenter. I'm just a Electrical Engineer .... all the "symbol part" of the code, you can replace it...

26 Jan 2011 Daniel Lopes

Nice code! Well done!
You should try to combine it with the implicitplot3d(.)[go this website http://www-users.math.umd.edu/~jmr/241/surfaces.html].
It realy gives an excelent visual result as an alternative to the cranky mesh from isosurface(.) :S.

%% ____________________________________
figure,
syms x y z;
h=x^2+y^2+z^2;
implicitplot3d(h, 1, -3, 3, -3, 3, -3, 3, 40); axis equal
hold on
ezimplot3(h-1,[-5 5])

22 Jun 2011 Shahab

Nice Job Gustavo
I just needed an implicit plot in the middle of my code somewhere to show an obstacle...
You saved me a few days of work.
Thx man

02 Jun 2012 Gkcn

Dear Gustavo,thank you for your useful function.I tried to use it for plotting my own equation but it gives many surfaces together although i need only one surface around first root of my equation.Please can you help me how can i find it?
my equation is:

tan(sqrt(y)*(1-1/x)*z)-sqrt(y)*(x-z^2)/(x+y)*z=0

1<=x<=10 , 0.1<=y<=10 , 0<=z<=1

Thank you in advance.

Please login to add a comment or rating.
Updates
12 Apr 2009

Better and corrected comments
Code easier to read
Now you can give it the name of your "function.m" file
A lot of input errors catched (I said "a lot", not "all") ;)

18 Apr 2009

*Now supports symbolic and inline classes as input
*Now you can pass it a 'color' argument
*Better comments
*Code was rearranged, so it would be more readable. One day ezimplot3 could connect with Matlab's "ezgraph3"

03 May 2009

-Cleaned some bugs up
-Now you can give an axis handle to make the plot
-Simplified code

07 Oct 2010

I've added information about the products required: Symbolic Math Toolbox

Tag Activity for this File
Tag Applied By Date/Time
surface Gustavo Morales 10 Apr 2009 15:42:04
implicit functions Gustavo Morales 10 Apr 2009 15:42:04
plotting Gustavo Morales 10 Apr 2009 15:42:04
graph types Gustavo Morales 10 Apr 2009 15:42:04
mathematics Gustavo Morales 10 Apr 2009 15:42:04
specialized plotting Gustavo Morales 15 Apr 2009 10:25:14
specialized plotting Tamara Kolda 29 Jul 2009 18:26:21
3d ezplot Tamara Kolda 29 Jul 2009 18:26:50
3d ezplot Dong Hun Park 09 Mar 2010 18:22:41
3d ezplot Roman Abramov 05 Jun 2010 05:18:28
implicit functions Mathias Vanwolleghem 24 Mar 2011 10:21:48
3d ezplot Stanley Liu 15 Apr 2011 22:58:14
implicit functions PRASMIT NAYAK 14 Apr 2012 06:31:13

Contact us at files@mathworks.com