Error using contour function

조회 수: 7 (최근 30일)
Tallha Khan
Tallha Khan 2018년 1월 3일
답변: Star Strider 2018년 1월 3일
When attempting to produce a contour plot of an equation i have named as Z. I am presented with the error shown below.
Can anyone help?

채택된 답변

Star Strider
Star Strider 2018년 1월 3일
You need to use ‘X’ and ‘Y’ in ‘Z’.
Try this:
x = linspace(-1, 1, 100);
y = linspace(-1, 1, 100);
[X,Y] = meshgrid(x, y);
a = x + 0.5;
b = y - 0.5;
Z = @(x,y) 1./sqrt(a.^2 + y.^2) - 2./sqrt(b.^2 + x.^2);
figure(1)
contour(X, Y, Z(X,Y))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by