Plotting curves defined by implicit functions Classic List Threaded 7 messages Open this post in threaded view
|

Plotting curves defined by implicit functions

 ezplot is one way to plot curves defined implicitly, but I would like to find something more flexible. I didn't find anything while searching around.Does anyone know of an alternative, or just know how ezplot works? I tried reading the code and could not follow the details.- Brett Green
Open this post in threaded view
|

Re: Plotting curves defined by implicit functions

 One possibility is to use contour:https://octave.org/doc/interpreter/Two_002dDimensional-Plots.html#XREFcontourFor example to plot the curve defined by the implicit equation  F(x,y)=0One could use  contour (x, y, F(x,y),0)I suspect this might be the approach taken internally by ezplot, but it might give you more control over options.c.Il 14 set 2019 20:48, Brett Green <[hidden email]> ha scritto:ezplot is one way to plot curves defined implicitly, but I would like to find something more flexible. I didn't find anything while searching around.Does anyone know of an alternative, or just know how ezplot works? I tried reading the code and could not follow the details.- Brett Green
Open this post in threaded view
|

Re: Plotting curves defined by implicit functions

 Thank you! I've used contours for this before, and was wondering if there was an alternative method streamlined for level curves, but that's probably just a pipe dream.On that subject, though, I have an issue with contour. Either I'm doing something mathematically inane or I'm misunderstanding how to call the function. I rune the code:F = @(x,y) x.^2+y.^2-4;x=linspace(-5,5,100);y=x;for k=1:100for j=1:100Fmat(k,j) = F(x(k),y(j));endendcontour(x,y,Fmat,0)and getwarning: division by zerowarning: called from    __contour__ at line 167 column 11    contour at line 74 column 18I thought I asked for a contour where Fmat=0, which should be a circle of radius 2. What am I missing here?- Brett GreenOn Mon, Sep 16, 2019 at 4:43 AM Carlo de Falco <[hidden email]> wrote:One possibility is to use contour:For example to plot the curve defined by the implicit equation  F(x,y)=0One could use  contour (x, y, F(x,y),0)I suspect this might be the approach taken internally by ezplot, but it might give you more control over options.c.Il 14 set 2019 20:48, Brett Green <[hidden email]> ha scritto:ezplot is one way to plot curves defined implicitly, but I would like to find something more flexible. I didn't find anything while searching around.Does anyone know of an alternative, or just know how ezplot works? I tried reading the code and could not follow the details.- Brett Green
Open this post in threaded view
|

Re: Plotting curves defined by implicit functions

 > Il giorno 16 set 2019, alle ore 16:55, Brett Green <[hidden email]> ha scritto: > > Thank you! I've used contours for this before, and was wondering if there was an alternative method streamlined for level curves, but that's probably just a pipe dream. > > On that subject, though, I have an issue with contour. Either I'm doing something mathematically inane or I'm misunderstanding how to call the function. I rune the code: > > F = @(x,y) x.^2+y.^2-4; > x=linspace(-5,5,100); > y=x; > for k=1:100 > for j=1:100 > Fmat(k,j) = F(x(k),y(j)); > end > end > contour(x,y,Fmat,0) > > and get > > warning: division by zero > warning: called from >     __contour__ at line 167 column 11 >     contour at line 74 column 18 > > I thought I asked for a contour where Fmat=0, which should be a circle of radius 2. What am I missing here? > > - Brett Green >> F = @(x,y) x.^2+y.^2-4; >> [x, y] = meshgrid (linspace (-5,5,100)); >> contour (x, y, F(x, y)) have a look at meshgrid in the manual. c.
Open this post in threaded view
|

Re: Plotting curves defined by implicit functions

 > Il giorno 17 set 2019, alle ore 07:02, [hidden email] ha scritto: > > > >> Il giorno 16 set 2019, alle ore 16:55, Brett Green <[hidden email]> ha scritto: >> >> Thank you! I've used contours for this before, and was wondering if there was an alternative method streamlined for level curves, but that's probably just a pipe dream. >> >> On that subject, though, I have an issue with contour. Either I'm doing something mathematically inane or I'm misunderstanding how to call the function. I rune the code: >> >> F = @(x,y) x.^2+y.^2-4; >> x=linspace(-5,5,100); >> y=x; >> for k=1:100 >> for j=1:100 >> Fmat(k,j) = F(x(k),y(j)); >> end >> end >> contour(x,y,Fmat,0) >> >> and get >> >> warning: division by zero >> warning: called from >>    __contour__ at line 167 column 11 >>    contour at line 74 column 18 >> >> I thought I asked for a contour where Fmat=0, which should be a circle of radius 2. What am I missing here? >> >> - Brett Green > > > >>> F = @(x,y) x.^2+y.^2-4; >>> [x, y] = meshgrid (linspace (-5,5,100)); >>> contour (x, y, F(x, y)) > > > have a look at meshgrid in the manual. > c. BTW, I think the best way to plot the curve you want in the example is   F = @(x, y) x.^2 + y.^2;   contour (x, y, F(x,y), [4 4]); The form for the last input is not documented clearly in the manual, I just posted a documentation bug about this  here :   https://savannah.gnu.org/bugs/?56907c.