# 2d plot of a non-linear equation

3 ビュー (過去 30 日間)
Gurra 2021 年 3 月 24 日
コメント済み: John D'Errico 2021 年 3 月 24 日
Hi,
How do I create a 2D plot of a two variable expression,say 1=y^5+y*x+x^2?
I am looking for some sort of Matlab function that simply plots the values of x and y which fullfills the expression. The approach should work for any two variable expression.
Thanks.

サインインしてコメントする。

### 採用された回答

Walter Roberson 2021 年 3 月 24 日
Example:
f = @(x,y) x + y.^2 - 0.5;
fimplicit(f)

サインインしてコメントする。

### その他の回答 (2 件)

John D'Errico 2021 年 3 月 24 日

Walter has already told you how to plot it. But so you can learn how to find that for yourself, learn to use lookfor.
The trick is to know this is called an IMPLICIT FUNCTION. And therefore, you might look for something in MATLAB to handle implicit functions. I tried this in MATLAB, and this is what it told me:
>> lookfor implicit
ode15i - Solve fully implicit differential equations, variable order method.
iburgersode - Burgers' equation solved as implicit ODE system
weissinger - Evaluate the residual of the Weissinger implicit ODE
fimplicit - Plot implicit function
fimplicit3 - Plot implicit surface
imex - Class for representing implicit-explicit schemes.
normal - Normal vector to an implicit surface represented by a CHEBFUN3.
bounds - Adds implicit bounds on variables.
bounds - Adds implicit bounds on variables.
Clearly we are not interested in the first 3 of those candidates. But fimplicit or fimplicit3 might be really valuable. You might now read the help for fimplicit and fimplicit3. I bet they would be useful.
Ok, but suppose you had no clue that this is called an implcit function in mathematics?
Now you might do your detective work differently. You want to plot something, and you want to plot a function, allowing MATLAB to do all the work for you. That would normally start with fplot. But fplot cannot handle such a problem.
But if I look at the help for fplot, at the bottom, there is always a see also line.
>> help fplot
...
And there I see a list of functions that you may also be interested in. Does fimplicit pop up there?
Or for a third way, if you think that fplot is something that MAY be helpful, where does fplot live?
>> which fplot
/Applications/MATLAB_R2020b.app/toolbox/matlab/graphics/function/fplot.m
So it lives with a variety of graphics utilities. Specifically, in the graphics/function directory.
>> help graphics/function
Contents of function:
fcontour - Plot function contour lines
fimplicit - Plot implicit function
fimplicit3 - Plot implicit surface
fmesh - Plot 3-D mesh
fplot - Plot 2-D function
fplot3 - Plot 3-D parametric curve
fsurf - Plot 3-D surface
matlab - is a package.
Again, there we see a line for fimplicit.
Now you would read the help for fimplicit, perhaps best done by
doc fimplicit
And there you will find a function to do exactly what you need.
In all of your searches, if you see a function that you do not know what it does, READ THE HELP FOR IT. And while it may not do what you need right now, tomorrow you might remember what you saw as something useful for your problem then.
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

Gurra 2021 年 3 月 24 日
@Walter Roberson and @John D'Errico, thanks for your answers. That's all I needed to know.
##### 1 件のコメント表示非表示 なし
John D'Errico 2021 年 3 月 24 日

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by