MATLAB应用技巧.doc_第1页
MATLAB应用技巧.doc_第2页
MATLAB应用技巧.doc_第3页
MATLAB应用技巧.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Taylor Series in MATLABThe statementssyms xf = 1/(5+4*cos(x)T = taylor(f,8)return T =1/9+2/81*x2+5/1458*x4+49/131220*x6which is all the terms up to, but not including, order eight in the Taylor series for f(x):Technically, T is a Maclaurin series, since its basepoint is a = 0. The commandpretty(T)prints T in a format resembling typeset mathematics: 2 4 49 61/9 + 2/81 x + 5/1458 x + - x 131220These commands syms xg = exp(x*sin(x)t = taylor(g,12,2);generate the first 12 nonzero terms of the Taylor series for g about x = 2. Next, plot these functions together to see how well this Taylor approximation compares to the actual function g: xd = 1:0.05:3; yd = subs(g,x,xd);ezplot(t, 1,3); hold on;plot(xd, yd, r-.)title(Taylor approximation vs. actual function);legend(Taylor,Function)plot Plot the real-world values of two fi objects against each otherSyntaxplot(a)plot(a,b)plot(a,b,s)plot(a1,b1,s1,a2,b2,s2,.)DescriptionThe plot function for fi objects works the same as the built-in plot function. plot(a) plots the columns of a versus their index. If a is complex, plot(a) is equivalent to plot(real(a),imag(a). In all other uses of plot, the imaginary part is ignored. plot(a,b) plots vector b versus vector a. If a or b is a matrix, then the vector is plotted versus the rows or the columns of the matrix, depending on which matches the dimension of the vector. If a is a scalar and b is a vector, length(b) disconnected points are plotted. You can plot with various line types, plot symbols, and colors using plot(a,b,s) where s is a character string composed of one element from any or all of the three columns in the following table.For example, plot(a,b,c+:) plots a cyan dotted line with a plus symbol at each data point.plot(a,b,bd) plots a blue diamond at each data point, but does not draw any line. plot(a1,b1,s1,a2,b2,s2,.) combines the plots defined by the (a,b,s) triples. For example, plot(a,b,y-,a,b,go) plots the data twice, with a solid yellow line interpolating green circles at the data points.1. 如何设置ezplot函数绘图的颜色h=ezplot(sin(x)set(h,Color,red)2. matlab填充颜色问题h=ezsurf(420-3*x-4*y)/4,50,70); set(h,facecolor,r);hold on; g=ezsurf(300-2*x-3*y)/2,50,70); set(g,facecolor,g)axis equal3. matlab填充颜色问题ezmesh(x2+y2,-2*pi,2*pi, -2*pi,2*pi)colormap(1 0 0)4. 如何将一个图中多个封闭曲线内填充不同的颜色n = 6;r = (0:n)/n;theta = pi*(-n:n)/n;X = r*cos(theta);Y = r*sin(theta);C = r*cos(2*theta);pcolor(X,Y,C)axis equal tight5. matlab中如何对一条曲线和X轴之间的区域进行颜色的填充,比如一个高斯曲线下对应不同X段范围填充不同的颜close allx = 0:0.1:pi;y = sin(x);area(x,y,FaceColor,r);hold onx = pi:0.1:2*pi;y = sin(x);area(x,y,FaceColor,g);x = 2*pi:0.1:3*pi;y = sin(x);area(x,y,FaceColor,b);axis(0,3*pi,-1,1)注意最后x轴坐标一定要设置,否则图像显示不完全。颜色的设置可以自己任意,将b,r等换成a b c格式的RGB色就可以。6. 关于matlab动画的问题h = 500; %h为初始高度x

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论