用于获得帮助文档,可以用help matlab中的注释是 %
>> help exp exp Exponential. exp(X) is the exponential of the elements of X, e to the X. For complex Z=X+i*Y, exp(Z) = exp(X)*(COS(Y)+i*SIN(Y)). See also expm1, log, log10, expm, expint. 重载的方法: zpk/exp tf/exp codistributed/exp gpuArray/exp fints/exp xregcovariance/exp sym/exp
>> a=[1,2,3;4,5,6] a = 1 2 3 4 5 6一些特殊的符号
转置矩阵
>> a' ans = 1 4 2 5 3 6
>> t=[0:0.1:10] t = Columns 1 through 13 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 Columns 14 through 26 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 Columns 27 through 39 2.6000 2.7000 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 Columns 40 through 52 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 Columns 53 through 65 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 6.4000 Columns 66 through 78 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 Columns 79 through 91 7.8000 7.9000 8.0000 8.1000 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 9.0000
t = linspace(n1,n2,n) 产生 从n1 到n2 的均匀分布的n个数
特殊矩阵 单位矩阵 0矩阵 对角矩阵
>> zeros(3) ans = 0 0 0 0 0 0 0 0 0 >> eye(2) ans = 1 0 0 1
>> diag(5) ans = 5结构体的定义,还有细胞数组的定义
直接用.用属性赋值的方法 来进行赋值
多项式的生成
>> p=[1,-6,11,6] p = 1 -6 11 6 >> poly2sym(p,'x') ans = x^3 - 6*x^2 + 11*x + 6
>> poly(5) ans = 1 -5还有多项式的计算
>> p=[1,3,2]; >> a=[1,2;3,4]; >> polyvalm(p,a) ans = 12 16 24 36
绘图的一些基本操作
>> p=[1,2,3]; >> a=[2,3,4]; >> plot(p,a)
>> x=0:0.25:5; >> y1 = x .^ 0.1; >> y2 = x .^ 0.5; >> y3 = x .^ 0.8; >> y4 = x .^ 1.5; >> t = 0:0.001:2*pi; >> hold on; >> plot(3 * cos(t), 3 * sin(t)) >> plot(x,y3,'gp--')
>> t = 0:pi/50:10*pi; >> plot3(sin(t),cos(t),t);
首先定义好 fun1 函数 随后在matlab 控制台进行加载
绘制等高线的函数
>> a = [1,2;3,4]; >> any(a) ans = 1 1 >> all(a) ans = 1 1 >> find(a) ans = 1 2 3 4
>> a = rand(1,10); >> fid = fopen('d,txt','w'); >> fprintf(fid,'%8.4f','w'); >> fclose(fid); >> load d.txt >> d d = [] >> fid = fopen('d,txt','w'); >> fid = fopen('d.txt','w'); >> fprintf(fid,'%8.4f','w');动画的制作
>> for j = 1:30 mesh(cos(4*pi*j/30)*z,z) m(j) = getframe end