Thread View: comp.soft-sys.matlab
2 messages
2 total messages
Started by Dennis Woo
Sun, 24 Jan 1993 23:34
Help! Plotting.
Author: Dennis Woo
Date: Sun, 24 Jan 1993 23:34
Date: Sun, 24 Jan 1993 23:34
31 lines
1315 bytes
1315 bytes
Hi Matlab expert,
I am trying to make a contour plot of a hyperparaboloid of a
two-variable function. The equation look like this:
z = 2*w0^2 + 3*w1^2 - 12*w0 - 8*w1 + 2*w0*w1 + 36
The minimum of z(w0,w1) is z(2.8,0.4)=17.6.
I entered the following lines in matlab:
[w0,w1]=meshdom(-5:.1:5,-5:.1:5);
z = 2*(w0.^2) + 3*(w1.^2) - 12*w0 - 8*w1
+ 2*(w0.*w1) + 36*ones(w0);
contour(z)
Instead of contours (these contours are ellipses) centered at (2.8,0.4)
with a z-value of 17.6, I got the contours centered at around
(85,60).
Could someone please let me know what I have done wrong.
Thanx a lot.
New Matlab user,
*****************************************************************
* Dennis Woo Department of Mechanical Engineering *
* E-mail: dwoo@unb.ca University of New Brunswick *
* Tel: (506) 453-4513 *
*****************************************************************
Re: Help! Plotting.
Author: Michael Maurer
Date: Mon, 25 Jan 1993 21:45
Date: Mon, 25 Jan 1993 21:45
23 lines
1263 bytes
1263 bytes
In <1993Jan24.233400.1494@jupiter.sun.csd.unb.ca> dwoo@jupiter.sun.csd.unb.ca (Dennis Woo) writes: >I entered the following lines in matlab: > > [w0,w1]=meshdom(-5:.1:5,-5:.1:5); > z = 2*(w0.^2) + 3*(w1.^2) - 12*w0 - 8*w1 > + 2*(w0.*w1) + 36*ones(w0); > contour(z) >Instead of contours (these contours are ellipses) centered at (2.8,0.4) >with a z-value of 17.6, I got the contours centered at around >(85,60). Your mistake is to omit the axes specifications to 'contour'. Without these, 'contour' will use the indices into the array 'z' as the x- and y-axes. Instead you should say contour(z,-5:.1:5,-5:.1:5) Good luck. -- ______________________________________________________________________ Michael Maurer maurer@nova.stanford.edu (415) 723-1024
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads