Matlab question, just checking If i inputted correctly.

  • Thread starter Thread starter goonking
  • Start date Start date
  • Tags Tags
    Matlab
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
3 replies · 1K views · last reply
goonking
Messages
434
Reaction score
3

Homework Statement


Printed text instructions: Develop the M file to draw the contour curve and surface together of the function f(x,y) = -xye^(-x^2-y^2) in the square defined -2 ≤ x ≤ 2 and 2 ≤ y ≤ 2. Also label all the axes and graph should have a title that includes your name. Publish your output to HTML.


Homework Equations

The Attempt at a Solution


MATLAB script showing linspace grids, meshgrid, z = -x*y*exp(-x.^2 - y.^2), contour(x,y,z), and xlabel, ylabel, zlabel calls.

look at line4, did I enter it correctly?
I must have did something wrong because there is no contour at all, all i see are parallel lines.
 
Physics news on Phys.org
You are probably intending to use element-by-element multiplication, but you have used matrix multiplication. You need to use the .* operator instead.
 
.
 
Attachments
  • MATLAB 3D plot in a bounding box with axes from -2 to 2 and vertical range -1 to 1, showing multicolored contour curves in colors like blue, yellow and green on two level planes.
    upload_2015-7-12_15-35-58.png
    6.3 KB · Views: 419
  • Screenshot of a six-line MATLAB script: x and y defined with linspace(-2,2,30), meshgrid(x,y), z = -x.*y.*exp(-(x.^2+y.^2)), clf, and contour(x,y,z).
    upload_2015-7-12_15-36-56.png
    2 KB · Views: 461
Last edited:
You need to explain whether you solved the problem or not. It's now unclear whether you need help or not.