I got error in plotting

1 回表示 (過去 30 日間)
Habib
Habib 2016 年 6 月 25 日
編集済み: Walter Roberson 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 Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by