2matlab基本使用方法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
(12+2*(7-4))/3^2
ans =
2
format short;pi
ans =
3.1416
format long;pi
ans =
3.141592653589793
format rat;pi
ans =
355/113
format long;vpa(pi,50)
ans =
3.141592653589793115997963468544185161590576171875
who
Your variables are:
ans
a=randn(4)
a =
-0.1241 0.6715 0.4889 0.2939
1.4897 -1.2075 1.0347 -0.7873
1.4090 0.7172 0.7269 0.8884
1.4172 1.6302 -0.3034 -1.1471
whos
Name Size Bytes Class Attributes
a 4x4 128 double
ans 1x1 8 double
who
Your variables are:
a ans
what
M-files in the current directory E:\Matlab2010\智能仿生算法\遗传算法TSP_SuiJiSuanFa ZhuanJiaXiTongP167 fun_SuiJiSuanFa TSPrun_SuiJiSuanFa f fun_SuiJiSuanFa0
ZhuanJiaXiTongP162 f1 fun_SuiJiSuanFa2
MAT-files in the current directory E:\Matlab2010\智能仿生算法\遗传算法
my27city
dir
. ZhuanJiaXiTongP162.asv f.m my27city.mat
.. ZhuanJiaXiTongP162.m f1.m temp
3d.asv ZhuanJiaXiTongP167.asv fun_SuiJiSuanFa.asv temp.prj
3d.m ZhuanJiaXiTongP167.m fun_SuiJiSuanFa.m zia03836
New Folder bou2_4l.shp fun_SuiJiSuanFa0.asv TSP_SuiJiSuanFa.m da fun_SuiJiSuanFa0.m TSPrun_SuiJiSuanFa.m da.prj fun_SuiJiSuanFa2.m type 3d
clf;
x=-3:0.1:3;
y=-3:0.1:3;
[X Y]=meshgrid(x,y);
Z=f(X,Y)+4;
mesh(X,Y,Z);
hold on;
plot3(-0.7,-1,f(-0.7,-1)+4,'g*');
contour(X,Y,Z,'r');
which rand
built-in (D:\Program Files\MATLAB\R2010a\toolbox\matlab\randfun\rand) which 3d.m
E:\Matlab2010\智能仿生算法\遗传算法\3d.m
help exist
EXIST Check if variables or functions are defined.
EXIST('A') returns:
0 if A does not exist
1 if A is a variable in the workspace
2 if A is an M-file on MATLAB's search path. It also returns 2 when
A is the full pathname to a file or when A is the name of an ordinary file on MATLAB's search path
3 if A is a MEX-file on MATLAB's search path
4 if A is a MDL-file on MATLAB's search path
5 if A is a built-in MATLAB function
6 if A is a P-file on MATLAB's search path
7 if A is a directory
8 if A is a Java class
EXIST('A') or EXIST('A.EXT') returns 2 if a file named 'A' or
'A.EXT'
and the extension isn't a P or MEX function extension.
EXIST('A','var') checks only for variables.
EXIST('A','builtin') checks only for built-in functions.
EXIST('A','file') checks for files or directories.
EXIST('A','dir') checks only for directories.
EXIST('A','class') checks only for Java classes.
If A specifies a filename, MATLAB attempts to locate the file,
examines the filename extension, and determines the value to
return based on the extension alone. MATLAB does not examine
the contents or internal structure of the file.
When searching for a directory, MATLAB finds directories that are part
of MATLAB's search path. They can be specified by a partial path. It
also finds the current working directory specified by a partial path,
and subdirectories of the current working directory specified by
a relative path.
EXIST returns 0 if the specified instance isn't found.
See also DIR, WHAT, ISEMPTY, PARTIALPATH.
Overloaded methods:
inline/exist
fittype/exist
Composite/exist
Reference page in Help browser
doc exist
matlabroot
ans =
D:\Program Files\MATLAB\R2010a
diary('myJog')
c=rand(5)
c =
0.1839 0.9448 0.3692 0.4039 0.5752
0.2400 0.4909 0.1112 0.0965 0.0598
0.4173 0.4893 0.7803 0.1320 0.2348
0.0497 0.3377 0.3897 0.9421 0.3532
0.9027 0.9001 0.2417 0.9561 0.8212
diary off
d=randn(6)
d =
-1.3320 -0.1303 -0.8487 0.6601 0.0513 0.1832
-2.3299 0.1837 -0.3349 -0.0679 0.8261 -1.0298