matlab.docx
- 文档编号:28913277
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:19
- 大小:237.89KB
matlab.docx
《matlab.docx》由会员分享,可在线阅读,更多相关《matlab.docx(19页珍藏版)》请在冰豆网上搜索。
matlab
>>B=[1+9*i,2+8*i,3+7*j;4+6*j5+5*i,6+4*i;7+3*i,8+2*j1*i]
B=
1.0000+9.0000i2.0000+8.0000i3.0000+7.0000i
4.0000+6.0000i5.0000+5.0000i6.0000+4.0000i
7.0000+3.0000i8.0000+2.0000i0+1.0000i
>>v1=0:
0.2:
pi
v1=
Columns1through11
00.20000.40000.60000.80001.00001.20001.40001.60001.80002.0000
Columns12through16
2.20002.40002.60002.80003.0000
>>v2=0:
-0.1:
pi
v2=
Emptymatrix:
1-by-0
>>v3=0:
pi
v3=
0123
>>v4=pi:
-1:
0
v4=
3.14162.14161.14160.1416
A.^A
ans=
1427
256312546656
823543167772161
>>A=[1,2,3;4,5,6;7,8,0]
A=
123
456
780
>>find(A>=5)'
ans=
3568
>>[i,j]=find(A>=5);[i,j]
ans=
31
22
32
23
>>all(A>=5)
ans=
000
>>any(A>=5)
ans=
111
>>symss;p=(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
p=
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
>>simple(p)
simplify:
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
radsimp:
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
combine(trig):
s^7+21*s^6+185*s^5+883*s^4+2454*s^3+3944*s^2+3360*s+1152
factor:
(s+3)^2*(s+2)*(s+1)*(s+4)^3
expand:
s^7+21*s^6+185*s^5+883*s^4+2454*s^3+3944*s^2+3360*s+1152
combine:
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
convert(exp):
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
convert(sincos):
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
convert(tan):
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
collect(s):
s^7+21*s^6+185*s^5+883*s^4+2454*s^3+3944*s^2+3360*s+1152
mwcos2sin:
(s+3)^2*(s^2+3*s+2)*(s^3+12*s^2+48*s+64)
ans=
(s+3)^2*(s+2)*(s+1)*(s+4)^3
symsabcdt;
>>f=cos(a*t+b)+sin(c*t)*sin(d*t);
>>f1=taylor(f);
>>latex(f1)
ans=
\cos\left(b\right)-\sin\left(b\right)at+\left(-1/2\,\cos\left(b\right){a}^{2}+cd\right){t}^{2}+1/6\,\sin\left(b\right){a}^{3}{t}^{3}+\left(1/24\,\cos\left(b\right){a}^{4}-1/6\,c{d}^{3}-1/6\,{c}^{3}d\right){t}^{4}-{\frac{1}{120}}\,\sin\left(b\right){a}^{5}{t}^{5}
理解取值函数:
>>A=[-0.2765,0.5772,1.4597,2.1091,1.191,-1.6187];
>>floor(A)
ans=
-10121-2
>>ceil(A)
ans=
01232-1
>>round(A)
ans=
01121-2
>>fix(A)
ans=
00121-1
3*3的Hilbert矩阵可以由A=hilb(3)定义
>>A=hilb(3);[n,d]=rat(A)
n=
111
111
111
d=
123
234
345
似求1856120与1483720的最大公约数与最小公倍数
m=sym(1856120);
>>n=sym(1483720);
>>[gcd(m,n),lcm(m,n)]
ans=
[1960,1405082840]
》factor(lcm(n,m))
ans=
(2)^3*(5)*(7)^2*(757)*(947)
1到1000之间的质数
>>A=1:
1000;B=A(isprime(A))
B=
Columns1through19
2357111317192329313741434753596167
Columns20through38
717379838997101103107109113127131137139149151157163
Columns39through57
167173179181191193197199211223227229233239241251257263269
Columns58through76
271277281283293307311313317331337347349353359367373379383
Columns77through95
389397401409419421431433439443449457461463467479487491499
Columns96through114
503509521523541547557563569571577587593599601607613617619
Columns115through133
631641643647653659661673677683691701709719727733739743751
Columns134through152
757761769773787797809811821823827829839853857859863877881
Columns153through168
883887907911919929937941947953967971977983991997
求满足
大于1000的最小m值
>>s=0;m=0;
>>while(s<=10000),m=m+1;s=s+m;end,[s,m]
ans=
10011141
求解级数求和问题s=
>>tic,s=0;fori=1:
100000,s=s+1/i^i+1/3^i;end;toc
Elapsedtimeis0.420000seconds.
>>tic,i=100000;s=sum(1./2^i+1./3^i);toc
Elapsedtimeis0.073000seconds.
试绘制y=sin(tan(x)-tan(sin(x))在[-pi,pi]的图像
x=[-pi:
0.05:
pi];
>>y=sin(tan(x))-tan(sin(x));
>>plot(x,y)
>>
x=[-2:
0.02:
2];
>>y=1.1*sign(x).*(abs(x)>1.1)+x.*(abs(x)<=1.1);plot(x,y)
ezplot('x^2*sin(x+y^2)+y^2*exp(x+y)+5*cos(x^2+y)')
ezplot('x^2*sin(x+y^2)+y^2*exp(x+y)+5*cos(x^2+y)',[-1010])
t=0:
.1:
2*pi;
>>x=t.^3.*sin(3*t).*exp(-t);y=t.^3.*cos(3*t).*exp(-t);z=t.^2;
>>plot3(x,y,z),grid
t=0:
.1:
2*pi;
>>x=t.^3.*sin(3*t).*exp(-t);y=t.^3.*cos(3*t).*exp(-t);z=t.^2;
>>plot3(x,y,z),grid
>>stem3(x,y,z);holdon;plot3(x,y,z),grid
[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);
>>z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);
>>z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
>>surf(x,y,z)
[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);
>>z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
>>waterfall(x,y,z)
[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);
>>z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
>>contour3(x,y,z,30)
[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);
>>z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
>>surf(x,y,z)
>>shadinginterp
[x,y]=meshgrid(0:
31);n=2;DO=200;
D=sqrt((x-16).^2+(y-16).^2);
z=1./(1+D.^(2*n)/DO);mesh(x,y,z),axis([0,31,0,31,0,1])
surf(x,y,z)
>>shadingflat
>>[x,y]=meshgrid(-2:
.1:
2);
>>z=1./(sqrt((1-x).^2+y.^2))+1./(sqrt((1+x).^2+y.^2));
Warning:
Dividebyzero.
Warning:
Dividebyzero.
>>surf(x,y,z),shadingflat
>>
xx=[-2:
.1:
-1.2,-1.1:
0.02:
-0.9,-0.8:
0.1:
0.8,0.9:
0.02:
1.1,1.2:
0.1:
2];
>>yy=[-1:
0.1:
-0.2,-0.1:
0.02:
0.1,0.2:
.1:
1];
>>[x,y]=meshgrid(xx,yy);
>>z=1./(sqrt((1-x).^2+y.^2))+1./(sqrt((1+x).^2+y.^2));
Warning:
Dividebyzero.
Warning:
Dividebyzero.
>>surf(x,y,z),shadingflat;set(gca,'zlim',[0,15])
>>[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);z=1./(1+D.^(2*n)/DO);
>>subplot(221),surf(x,y,z),vi
ew(0,90);axis([0,31,0,31,0,1]);俯视图
>>[x,y]=meshgrid(0:
31);n=2;DO=200;
>>D=sqrt((x-16).^2+(y-16).^2);z=1./(1+D.^(2*n)/DO);
>>subplot(221),surf(x,y,z),view(0,90);axis([0,31,0,31,0,1]);
>>subplot(222),surf(x,y,z),view(90,0);axis([0,31,0,31,0,1]);
>>subplot(223),surf(x,y,z),view(0,0);axis([0,31,0,31,0,1]);
>>subplot(224),surf(x,y,z),axis([0,31,0,31,0,1]);
>>
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab