I got error in plotting

1 Ansicht (letzte 30 Tage)
Habib
Habib am 25 Jun. 2016
Bearbeitet: Walter Roberson am 25 Jun. 2016
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?

Akzeptierte Antwort

KSSV
KSSV am 25 Jun. 2016
Bearbeitet: KSSV am 25 Jun. 2016
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)

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by