第一章M A T L A B概况与基本操作
1.选择题:
(1)最初的MATLAB核心程序是采用A语言编写的。
A.FORTRAN
B.C
C.BASIC
D.PASCAL
(2)即将于2011年9月发布的MATLAB新版本的编号为D。
A.MATLAB 2011Ra
B.MATLAB 2011Rb
C.MATLAB R2011a
D.MATLAB R2011b
(3)在默认设置中,MATLAB中的注释语句显示的颜是D。
A.黑
matlab考试题库及答案B.蓝
C.红
D.绿
(4)如果要以科学计数法显示15位有效数字,使用的命令是B。
A.format long
B.format long e
C.format long g
D.format long d
(5)在命令窗口新建变量a、b,如果只查看变量a的详细信息,使用的命令为B。
A.who a
B.whos a
C.who
D.whos
(6)如果要清除工作空间的所有变量,使用的命令为 C 。
A.clear
B.clear all
C.两者都可
D.两者都不可
(7)在创建变量时,如果不想立即在命令窗口中输出结果,可以在命令后加上D。
A.冒号
B.逗号
C.空格
D.分号
(8)如果要重新执行以前输入的命令,可以使用B键。
A.下箭头↓
B.上箭头↑
C.左箭头←
D.右箭头→
(9)如果要查询函数inv的相关信息,并显示在命令窗口,应使用命令A。
A.help
B.lookfor
C.doc
D.三者均可
(10)如果要启动Notebook文档,下列D操作是可行的。
A.在命令窗口输入notebook命令
B.在命令窗口输入notebook filename命令
C.在Word中启动M-book文档
D.三者均可
2.填空题:
(1)MATLAB是MATrix和LABoratory两个单词前三个字母的组合,意为“矩阵实验室”,它的创始人是Cleve Moler和Jack Little。
(2)在MATLAB的默认设置中,关键字显示的字体为蓝,命令、表达式、计算结果显示的字体为黑,字符串显示的字体为紫,注释显示的字体为绿,错误信息显示的字体为红。
(3)在命令窗口中,输出结果显示为各行之间添加空行的命令为format compact,各行之间不添加空行的命令为format compact。
备注:本题布置给大家时有一点小错误,现在予以更正。
(4)在MATLAB中,各种标点符号的作用是不同的。例如,空格的作用是分隔数组中每一行的各个元素,逗号的作用是分隔数组中每一行的各个元素或不同的命令,分号的作用是分隔数组中的各行或控制命令执行结果是否在命令窗口显示,冒号的作用是生成一维数组或显示全部元素,百分号的作用是注释行的开头,…的作用是把相邻两行的语句连接为一个命令,感叹号的作用是执行操作系统命令。
3.先建立自己的工作目录,再将自己的工作目录设置到MATLAB搜索路径下。请写出操作步骤或用Matlab命令实现。用help命令能查询到自己的工作目录吗?
解:操作步骤:
(1)在Windows环境中建立一个工作目录,如:c:\mywork;
(2)启动MATLAB,在File菜单中选择Set Path…命令,显示出如下图的对话框:
(3)选择Add Folder…按钮,又显示出如下图的对话框:
(4)在该对话框中到c:\mywork文件夹,选择确定按钮。
(5)返回步骤(2)的对话框,选择Save按钮,然后选择Close按钮,关闭对话框。(注意:选择Save和Close按钮的次序不能错,如果先选择Close按钮,就会直接关闭对话框,而不会将你的工作目录添加到搜索路径中。
采用这种方法设置的工作路径是永久性的,只要不在步骤(2)的对话框中选择Remove按钮移除该文件夹,那么你在该文件夹中保存的文件MATLAB总能到。
4.利用MATLAB的帮助功能分别查询inv、plot、max、round等函数的功能及用法。
解:所使用的命令分别为
help inv
INV Matrix inverse.
INV(X) is the inverse of the square matrix X.
A warning message is printed if X is badly scaled or
nearly singular.
See also SLASH, PINV, COND, CONDEST, LSQNONNEG, LSCOV.
Overloaded functions or methods (ones with the same name in other directories) help gf/inv.m
help lti/inv.m
help idmodel/inv.m
help atom/inv.m
help ndlft/inv.m
help ufrd/inv.m
help umat/inv.m
help uss/inv.m
help sym/inv.m
Reference page in Help browser
doc inv
help plot
PLOT Linear plot.
PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, disconnected
line objects are created and plotted as discrete points vertically at
X.
PLOT(Y) plots the columns of Y versus their index.
If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).
In all other uses of PLOT, the imaginary part is ignored.
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.
PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X's and Y's are vectors or matrices
and the S's are strings.
For example, PLOT(X,Y,'y-',X,Y,'go') plots the data twice, with a
solid yellow line interpolating green circles at the data points.
The PLOT command, if no color is specified, makes automatic use of
the colors specified by the axes ColorOrder property. The default
ColorOrder is listed in the table above for color systems where the
default is blue for one line, and for multiple lines, to cycle
through the first six colors in the table. For monochrome systems,
PLOT cycles over the axes LineStyleOrder property.
If you do not specify a marker type, PLOT uses no marker.
If you do not specify a line style, PLOT uses a solid line.
PLOT(AX,...) plots into the axes with handle AX.
PLOT returns a column vector of handles to lineseries objects, one
handle per plotted line.
The X,Y pairs, or X,Y,S triples, can be followed by
parameter/value pairs to specify additional properties
of the lines. For example, PLOT(X,Y,'LineWidth',2,'Color',[.6 0 0])
will create a plot with a dark red line width of 2 points.
Example
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x,y,'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
See also PLOTTOOLS, SEMILOGX, SEMILOGY, LOGLOG, PLOTYY, PLOT3, GRID,
TITLE, XLABEL, YLABEL, AXIS, AXES, HOLD, LEGEND, SUBPLOT, SCATTER, PLOT3.
Overloaded functions or methods (ones with the same name in other directories) help SimTimeseries/plot.m
help timeseries/plot.m
help phytree/plot.m
help channel/plot.m
help cfit/plot.m
help darray/plot.m
help fints/plot.m
help iddata/plot.m
help idfrd/plot.m
help idmodel/plot.m
help idnlarx/plot.m
help idnlhw/plot.m
help cgrules/plot.m
help localavfit/plot.m
help localmod/plot.m
help localmulti/plot.m
help xregarx/plot.m
help xregmodel/plot.m
help xregtransient/plot.m
help xregtwostage/plot.m
help mdevtestplan/plot.m
help sweepset/plot.m
help cgdatasetnode/plot.m
help mpc/plot.m
help rfckt/plot.m
help frd/plot.m
help dspdata/plot.m
help dtree/plot.m
help ntree/plot.m
help wdectree/plot.m
help edwttree/plot.m
help rwvtree/plot.m
help wvtree/plot.m
Reference page in Help browser
doc plot
help max
help round
备注:后两个命令的执行结果这里就不再显示出来了,同学们可以自己执行一下。当然,使用lookfor、doc两个命令也是可以的。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论