大家好,欢迎来到IT知识分享网。
2.开平方-sqrt(x)
3.指数函数exp(x)
4.clc清除窗口显示内容的命令
5.who、whos命令用来清除工作空间的变量
6.clear命令用来清除工作空间的变量
7.dir显示当前工作目录的文件和子目录清单
8.cd显示或设置当前工作目录
9.type显示指定m文件的内容
10.help或doc获取在线帮助
x =
1.0000 1.2500 1.5000 1.7500 2.0000
a =
a =
1.0000 3.2500 5.5000 7.7500 10.0000
>> a(3)%寻访a的第3个元素
ans =
5.5000
>> a([1 2 5])%寻访a的第1、2、5个元素组成的子数组
ans =
ans =
1.0000 3.2500 5.5000
>> a(3:-1:1)%由前3个元素倒序构成的子数组
ans =
5.5000 3.2500 1.0000
>> a(3:end)%第3个元素及其后的所有元素构成的子数组
ans =
5.5000 7.7500 10.0000
>> a(3:end)%第3个元素及其后的所有元素构成的子数组,end作为参数使用,返回最后一个元素的下标
ans =
ans =
a =
1.0000 3.2500 0 7.7500 10.0000
>> a([2 5])=[1 1]%可以修改指定数组元素的值,一次可以修改多个数组元素的值,要修改的数组元素的个数应与送入数组的元素个数相同
a =
a_2 =
>> a_2(:)=1:8
a_2 =
>> a_2([2 5 8])%单下标方式寻访多个元素
ans =
2 5 8
>> a_2([2 5 8])=[10 20 30]
a_2 =
>> a_2(:,[2 3])=ones(2)%双下标方式寻访并修改
a_2 =
str3 =
ans =
17
>> sentenceAscii=double(sentence)%查看字符串sentence的ASCII码
sentenceAscii =
73 32 39 118 101 32 103 111 116 32 97 32 100 97 116 101 33
>> sentence2=char(sentenceAscii)%将ASCII码恢复成字符串形式
sentence2 =
out1 =
char
>> out2=ischar(Chinese)%out2的值是1,代表Chinese是字符串变量
out2 =
1
out3 =
out1 =
0
>> out2=strcmp(str1,str3)%比较字符串str1和str3
out2 =
a =
c =
[3×3 double]
>> c(1,2)={‘Anne Smith’}
c =
[3×3 double] ‘Anne Smith’
>> c(2,1)={3+7i}
c =
>> c(2,2)={-pi:pi/10:pi}
c =
>> class(c)
ans =
b =
‘James’
>> class(b)
ans =
cell
>> b{1,2}=[1 2;3 4;5 6]
b =
‘James’ [3×2 double]
>> b{2,1}=pi
b =
>> b{2,2}=zeros(5)
b =
a =
>> a=[b;c]
a =
a =
-3.1416 -2.8274 -2.5133 -2.1991 -1.8850 -1.5708 -1.2566 -0.9425 -0.6283 -0.3142 0
Columns 12 through 21
0.3142 0.6283 0.9425 1.2566 1.5708 1.8850 2.1991 2.5133 2.8274 3.1416
ans =
Anne Smith
>> a{:}%一次显示a的全部数据
b =
>> b,d=b{1,2}%读取b元胞数组的第1行、第2列元胞的内容
b =
>> e=b{1,2}(3,1)%读取b{1,2}的第3行、第1列的数据
e =
5
>> f=a(1,:)%读取元胞数组a第一行的所有元胞
f =
[3×3 double] ‘Anne Smith’
>> a(1,:)=[]%删除元胞数组a第一行的所有元胞
a =
[3.0000 + 7.0000i] [1×21 double]
student =
student =
1×2 struct array with fields:
>> student(1)
ans =
ans =
ans =
1×2 struct array with fields:
ans =
Newton
ans =
>> cat(2,student.scores)
ans =
50 60 60 70
average1 =
average2 =
65
例如:北京市从业人员统计
50.饼图指令pie
51.离散杆图stem
52.极坐标图polar
polar函数用来绘制极坐标图,其调用格式为:polar(theta,rho,选项)
>> imshow(img1);%显示图片
ans =
>> diag(1:3,-1)
ans =
ans =
ans =
x =
A =
>> B=det(A)
B =
0.0538
p =
1 -12 0 25 116
>> r=roots(p)
r =
r =
>> pp=poly(r)
pp =
1.0000 -12.0000 -0.0000 25.0000 116.0000
c =
1 6 20 50 75 84 64
两个以上的多项式的乘法需要重复使用conv。
d =
c =
1 6 20 50 75 84 64
>> e=c+[0 0 0 d]
e =
1 6 20 52 81 96 84
例如,编写一个多项式加法运算的函数文件
>> poly(c,d)
ans =
1 6 20 52 81 96 84
q =
1 2 3 4
0 0 0 0 0 0 0
举例:求b(x)=x^3+4x^2+9x=16的导数。
d =
3 8 9
(7)多项式的估值(polyval)
DY =
Columns 1 through 5
0.6428 0.3420 -0.1188 -0.5240 -0.6840
Columns 6 through 9
-0.5240 -0.1188 0.3420 0.6428
>> D2Y=diff(Y,2)
D2Y =
Columns 1 through 5
-0.3008 -0.4608 -0.4052 -0.1600 0.1600
Columns 6 through 8
0.4052 0.4608 0.3008
>> D3Y=diff(Y,3)
D3Y =
Columns 1 through 5
-0.1600 0.0556 0.2452 0.3201 0.2452
Columns 6 through 7
0.0556 -0.1600
Isim =
0.7468
0.7468
Isim =
0.8862
ans =
>> sort(-A,2)%对A的每行按降序排列
ans =
ans =
0.0000
>> interp1(x,f,0.472,’nearest’)
ans =
0.0000
>> interp1(x,f,0.472,’spline’)
ans =
ans =
0.2056
p =
Columns 1 through 2
0.0222 -0.0553
Columns 3 through 4
1.8795 -0.8138
>> y1=polyval(p,x)
y1 =
Columns 1 through 2
-0.8138 0.0637
Columns 3 through 4
0.6247 0.6122
Columns 5 through 6
0.7693 0.8392
Columns 7 through 8
0.5651 0.6901
Columns 9 through 10
0.9572 0.1097
Columns 11 through 12
-0.1096 -0.9570
Columns 13 through 14
-0.6898 -0.5648
Columns 15 through 16
-0.8388 -0.7687
Columns 17 through 18
-0.6114 -0.6236
Columns 19 through 20
-0.0625 0.8153
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/121700.html