matlab习题第一章

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第一章实验内容

1.

2.例1-1 x=[0:0.5:360]*pi/180; plot(x,sin(x),x,cos(x));

例1-2 p=[3,7,9,0,-23];

x=roots(p)

x =

-1.8857

-0.7604 + 1.7916i

-0.7604 - 1.7916i

1.0732

例1-3 quad('x.*log(1+x)',0,1) ans =

0.2500

例 1-4 a=[2,-3,1;8,3,2;45,1,-9]; b=[4;2;17];

x=inv(a)*b

x =

0.4784

-0.8793

0.4054

3.

(1)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…

(2)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…

(3)help max

max Largest component.

For vectors, max(X) is the largest element in X. For matrices,

max(X) is a row vector containing the maximum element from each

column. For N-D arrays, max(X) operates along the first

non-singleton dimension...

(4)help round

round Round towards nearest integer.

round(X) rounds the elements of X to the nearest integers.

4.(1) x=0:pi/10:2*pi;

y=sin(x)

y =

Columns 1 through 10

0 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090

Columns 11 through 20

0.0000 -0.3090 -0.5878 -0.8090 -0.9511 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090

Column 21

-0.0000

(2)根据提示操作,选择y变量,并绘制y图形,生成了如下图形,图形是一个正弦函数图像。

思考练习

1.与其他窗口程序的启动与退出类似,双击图标打开,单击X图标关闭

2. MATLAB是矩阵实验室(Matrix Laboratory)的简称用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境。它将数值分析、矩阵计算、科学数据可视化以及非线性动态系统的建模和仿真等诸多强大功能集成在一个易于使用的视窗环境中,为科学研究、工程设计以及必须进行有效数值计算的众多科学领域提供了一种全面的解决方案。

3.如果一个命令行很长,需要分成多行输入,可以在第一个物理行之后加上三个小黑点…并按下enter键,然后接着在下一个物理航继续输入命令的其他部分。三个小黑点称为续行符,即把下面的物理行看作该行的逻辑继续。

4.help命令只搜索出那些与关键字完全匹配的结果,lookfor命令对搜索范围内的小文件进行关键字搜索,条件比较宽松。

5.假如建立了一个变量fac,同时在当前目录下建立了一个M文件fac.m文件。如果在命令窗口输入fac,按照MATLAB的搜索顺序,应该在屏幕上显示fac的值。如果没有建立fac变量,则执行fac.m文件。

相关文档
最新文档