help-octave
[Top][All Lists]

## Re: Plotting curves defined by implicit functions

 From: Brett Green Subject: Re: Plotting curves defined by implicit functions Date: Thu, 19 Sep 2019 18:43:57 -0400

Thank you! The simple, if odd, fix of just using two entries in the argument which sets the contours works fine for me. It's good to know it wasn't because I was misunderstanding something.

- Brett Green

On Tue, Sep 17, 2019 at 1:26 AM <address@hidden> wrote:

> Il giorno 17 set 2019, alle ore 07:02, address@hidden ha scritto:
>
>
>
>> Il giorno 16 set 2019, alle ore 16:55, Brett Green <address@hidden> 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