MATLAB Answers

How to plot level curves

4 views (last 30 days)
Irene Zhou
Irene Zhou on 23 Nov 2020
Edited: VBBV on 23 Nov 2020
I have an equation Z = exp(-0.5.*((X-800)./40).^2).*cos(2*pi.*Y*1000./X).
I want to plot level curves of Y from -100 to 100 against X from 700 to 900 for Z = -1 to 1. The graph is supposed to look like the one below.
I have tried surf but it's ignoring the axis limits I set. I also don't know how to set Z to different values.
[X,Y] = meshgrid(700:1:900,-100:1:100);
Z = exp(-0.5.*((X-800)./40).^2)*cos(2*pi.*Y*1000./X);
surf(Z)
Any help is appreciated!

  0 Comments

Sign in to comment.

Answers (1)

VBBV
VBBV on 23 Nov 2020
Edited: VBBV on 23 Nov 2020
[X,Y] = meshgrid(700:1:900,-100:1:100); % assumed in nano and micro meters
Z = exp(-0.5.*((X-800)./40).^2)*cos((2*pi.*Y*1000./X)*pi/180);
contourf(X,(Y),Z)
From your figure, it appears like contourf function is used, surf produces 3D plot in a box

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!