Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matlab contour grap & saddle point (calculus)

Subject: matlab contour grap & saddle point (calculus)

From: John Wong

Date: 6 Jul, 2010 01:53:04

Message: 1 of 3

Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1

b) Based on the contour plot you found in a) estimate the coordinates of two saddle
points of the function in the region S defined in a). Mark the points using the Data
Cursor.


My code is as follows:
[code]
x=linspace (-2,2,25); y=linspace (-1,1,25);
[x y]=meshgrid (x,y)
z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
[C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
clabel (C,h); % the clabel function labels the level curves
[/code]

output image: http://i47.tinypic.com/2dalvyu.jpg

I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.

Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???

Any help is appreciated. Thank you

Subject: matlab contour grap & saddle point (calculus)

From: Aaron Clarke

Date: 10 Jul, 2010 04:14:05

Message: 2 of 3

The the pointy gaps between the two lightest green lines are the two saddle points. Roughly located at (0.5576,-1.0000) and (-1.0198,0.2598). It's a bit easier to tell if you plot your data as a surface plot:

[x y]=meshgrid (linspace (-2,2,25),linspace (-1,1,25));
z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
figure;
surf(x,y,z);
xlabel('x'); ylabel('y');
cameratoolbar('NoReset');
cameratoolbar('SetMode', 'orbit');

Cheers,

Aaron

"John Wong" <gokoproject@gmail.com> wrote in message <i0u2a0$gi9$1@fred.mathworks.com>...
> Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
> a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1
>
> b) Based on the contour plot you found in a) estimate the coordinates of two saddle
> points of the function in the region S defined in a). Mark the points using the Data
> Cursor.
>
>
> My code is as follows:
> [code]
> x=linspace (-2,2,25); y=linspace (-1,1,25);
> [x y]=meshgrid (x,y)
> z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
> [C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
> clabel (C,h); % the clabel function labels the level curves
> [/code]
>
> output image: http://i47.tinypic.com/2dalvyu.jpg
>
> I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.
>
> Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???
>
> Any help is appreciated. Thank you

Subject: matlab contour grap & saddle point (calculus)

From: John D'Errico

Date: 10 Jul, 2010 10:56:07

Message: 3 of 3

"John Wong" <gokoproject@gmail.com> wrote in message <i0u2a0$gi9$1@fred.mathworks.com>...
> Suppose f(x,y) = sin(3y-x^2+1)+cos(2y^2-2x)
> a) produce a labeled contour plot for -2 <= x <= 2, -1<= y<= 1
>
> b) Based on the contour plot you found in a) estimate the coordinates of two saddle
> points of the function in the region S defined in a). Mark the points using the Data
> Cursor.
>
>
> My code is as follows:
> [code]
> x=linspace (-2,2,25); y=linspace (-1,1,25);
> [x y]=meshgrid (x,y)
> z = sin(3.*y - x.^2 + 1) + cos(2.*y.^2 - 2.*x);
> [C h]=contour (x,y,z); % the "handle" matrix [C h] holds the graph for labelling
> clabel (C,h); % the clabel function labels the level curves
> [/code]
>
> output image: http://i47.tinypic.com/2dalvyu.jpg
>
> I don't really know how to tell from the graph. I tried to solve it using second derivative test in matlab, but the solution is very weird, which I can't really use it at this point.
>
> Is it true that the the gap (pointy-gap) between the two lightest green lines are the two saddle points???
>
> Any help is appreciated. Thank you

John,

Since you have done the work, I'll help you.

A saddle point is easy to find from a contour plot.
It is a point where a pair of contour lines (of the
same value) would almost "try" to cross. Those
green lines that almost touch are exactly that.

The locally linear approximation used inside the
contour engine will fail to approximate the
saddle point correctly anyway, even if you had
the exactly correct contour level at which the
saddle point happens. So it looks the way you
see it on the plot.

In fact, there appears to be a third saddle point
on this plot, just near the edge.

John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us