I got error in plotting

1 次查看(过去 30 天)
Habib
Habib 2016-6-25
Hi everyone,
I tried to plot a figure by contour command and after I defined a set command for make changing on K values but ,when I run it, I got a figure that is not my preferred shape. of course, if I defined "set" function as set(d,'levelstep',30); , I got a right figure and, at this time, below error has occurred.
Undefined function or variable 'k'.
Error in projetmatlab (line 10)
set(k,'levelstep',30);
my code is as follow:
close all
clear
clc
x=linspace(-4,4,200);
y=x;
[X, Y]=meshgrid(x,y);
V=1./sqrt((X-1).^2+(Y).^2+eps)-1./sqrt((X+1).^2+Y.^2+eps);
[Ex, Ey]=gradient(V);
[C, K]=contour(X,Y,V,[-2:0.1:2]);
set(k,'levelstep',30);
[C1, h]=contour(X,Y,sqrt(Ex.^2+Ey.^2),[0:0.01:0.5]);
so what is wrong?

采纳的回答

KSSV
KSSV 2016-6-25
编辑:KSSV 2016-6-25
close all
clear
clc
x=linspace(-4,4,200);
y=x;
[X, Y]=meshgrid(x,y);
V=1./sqrt((X-1).^2+(Y).^2+eps)-1./sqrt((X+1).^2+Y.^2+eps);
[Ex, Ey]=gradient(V);
[C, K]=contour(X,Y,V,[-2:0.1:2]);
set(K,'levelstep',30);
[C1, h]=contour(X,Y,sqrt(Ex.^2+Ey.^2),[0:0.01:0.5]);
In the set command it shall be 'K' (capital), you typed 'k' (small case)

更多回答(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