统计预测 与决策 实验报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1 0 0 0 0 0 0
0 2 0 0 0 0 0
0 0 3 0 0 0 0
FORMAT may be used to affect the spacing in the display of all
variables as follows:
FORMAT COMPACT Suppresses extra line-feeds.
FORMAT LOOSE Puts the extra line-feeds back in.
Columns 8 through 9
5.4978 6.2832
>> y=sin(t)
y =
Columns 1 through 7
0 0.7071 1.0000 0.7071 0.0000 -0.7071 -1.0000
Columns 8 through 9
-0.7071 -0.0000
在命令窗口中键入:who,看运行结果
for positive, negative and zero elements.
Imaginary parts are ignored.
FORMAT BANK Fixed format for dollars and cents.
FORMAT RAT Approximation by ratio of small integers.
0 0 0 0 0
>> A1=eye(4)
A1 =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> B1=eye(4,5)
B1 =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
>> C1=eye(6,4)
C1 =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
for the class of the variable. For float variables, the default is
FORMAT SHORT.
FORMAT does not affect how MATLAB computations are done. Computations
on float variables, namely single or double, are done in appropriate
floating point precision, no matter how those variables are displayed.
Computations on integer variables are done natively in integer. Integer
variables are always displayed to the appropriate number of digits for
←,Ctrl-B
光标左移一个字符
→ ,Ctrl-F
光标右移一个字符
Home
光标移到行首
End
光标移到行尾
Esc
清除命令行
Del
删除光标处字符
Backspace
删除光标左边字符
Ctrl-K
删除至行尾
3.命令历史窗口
(1)将命令历史窗口中的语句复制到命令窗口中;
(2)直接双击命令历史窗口中的语句.
答:这两种方式都能执行命令历史窗口中的语句
a =
1 2 3 4
2 3 4 5
3 4 5 6
(2)构造特殊数组
>> A=ones(4,5)
A =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
>> B=zeros(6,1)
B =
0
0
0
0
0
0
>> C=zeros(3,5,'uint32')
C =
0 0 0 0 0
0 0 0 0 0
FORMAT may be used to switch between different output display formats
of all numeric variables as follows:
FORMAT HEX Hexadecimal format.
FORMAT + The symbols +, - and blank are printed
>> C=(1:5.8)
C =
1 2 3 4 5
(2)用linspace函数构造一维数组
>> x=linspace(0,2*pi,5)
x =
0 1.5708 3.1416 4.7124 6.2832
5.练习在MATLAB中构造二维数组(矩阵)的方法。
(1)简单创建方法
>> a=[1 2 3 4;2 3 4 5;3 4 5 6]
Overloaded functions or methods (ones with the same name in other directories)
help quantizer/format.m
Reference page in Help browser
doc format
②doc format
在命令窗口中键入:whos y,看运行结果。
>> whos y
Name Size Bytes Class
y 1x9 72 double array
Grand total is 9 elements using 72 bytes
5.帮助浏览器
使用帮助浏览器可以搜索和查询所有MathWorks产品的文档和演示。帮助浏览器是集成到MATLAB桌面的一个HTML查看器。
'try'
'while'
3.输入格式
练习使用format命令设置变量的输出格式。
答:
(1)format:以5位定点格式输出变量值。
(2)format long:以15位定点格式输出double型变量值
(3)format +:在矩阵中,用符号+、-和空格分别表示正号、负号和零。
4.练习在MATLAB中构造一维数组的方法。
format, intmax('uint64'), realmax
shows these values as 18446744073709551615 and 1.7977e+308 while
format hex, intmax('uint64'), realmax
shows them as ffffffffffffffff and 7fefffffffffffff respectively.
0 0 0 0
0 0 0 0
>> a=[1 2 3 4 5 6]
a =
1 2 3 4 5 6
>> A2=diag(a)
A2 =
1 0 0 0 0 0
0 2 0 0 0 0
0 0 3 0 0 0
0 0 0 4 wk.baidu.com 0
0 0 0 0 5 0
0 0 0 0 0 6
>> B2=diag(a,-1)
B2 =
0 0 0 0 0 0 0
of all float variables as follows:
FORMAT SHORT Scaled fixed point format with 5 digits.
FORMAT LONG Scaled fixed point format with 15 digits for double
>> who
Your variables are:
t y
在命令窗口中键入:whos,看运行结果
>> whos
Name Size Bytes Class
t 1x9 72 double array
y 1x9 72 double array
Grand total is 18 elements using 144 bytes
实验一:了解数学软件MATLAB
1.启动按钮
2.命令窗口
>> a=[1 2 3;4 5 6;7 8 9]
a =
1 2 3
4 5 6
7 8 9
>> a=[1 2 3;4 5 6;7 8 9];
因此,不加分号显示数组,加分号不显示数组
功能键
功能
↑,Ctrl-P
重新调入上命令行
↓,Ctrl-N
重新调入下命令行
分别使用Help函数和doc函数获取format函数的帮助,进而说明format函数的功能。
①help format
FORMAT Set output format.
FORMAT with no inputs sets the ouput format to the default appropriate
The HEX display corresponds to the internal representation of the value
and is not the same as the hexadecimal notation in the C programming
language.
See also disp, display, isnumeric, isfloat, isinteger.
Example:
format short, pi, single(pi)
displays both double and single pi with 5 digits as 3.1416 while
format long, pi, single(pi)
displays pi as 3.14159265358979 and single(pi) as 3.1415927.
>> huge=exp(log(realmax))
huge =
1.7977e+308
toobig=pi*huge
>> toobig=pi*huge
toobig =
Inf
2.变量
函数iskeyword的功能是:MATLAB预留了一些关键字并且不允许重载它们,如果调用过程中使用了它们,将会导致出错信息,使用不带输入变量的iskeyword函数可以列出所有预留的关键字。
the class, for example, 3 digits to display the INT8 range -128:127.
FORMAT SHORT and LONG do not affect the display of integer variables.
FORMAT may be used to switch between different output display formats
实验二:数学软件MATLAB的数据类型
1.常数
在命令窗口中分别键入:
Rho=(sqrt(5)-1)/2
>>Rho=(sqrt(5)-1)/2
Rho=
0.6180
A=abs(3+4i)
>> A=abs(3+4i)
A =
5
realmax
>> realmax
ans =
1.7977e+308
huge=exp(log(realmax))
and 7 digits for single.
FORMAT SHORT E Floating point format with 5 digits.
FORMAT LONG E Floating point format with 15 digits for double and
7 digits for single.
4.工作空间窗口
清除工作空间的命令是:clc
清除命令窗口的命令是:clear
在命令窗口中键入:
t=0:pi/4:2*pi
y=sin(t)
答:
>> t=0:pi/4:2*pi
t =
Columns 1 through 7
0 0.7854 1.5708 2.3562 3.1416 3.9270 4.7124
FORMAT SHORT G Best of fixed or floating point format with 5 digits.
FORMAT LONG G Best of fixed or floating point format with 15 digits
for double and 7 digits for single.
>> x=[1 2 3 4 5 6]
x =
1 2 3 4 5 6
(1)用增量法构建一维数组
>> A=(1:0.2:2)
A =
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
>> B=(1:0.2:2.1)
B =
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000
在命令窗口中键入命令iskeyword并记结果。
>> iskeyword
ans =
'break'
'case'
'catch'
'continue'
'else'
'elseif'
'end'
'for'
'function'
'global'
'if'
'otherwise'
'persistent'
'return'
'switch'
相关文档
最新文档