MATLAB应用技巧.doc

上传人:汽*** 文档编号:559239098 上传时间:2023-02-04 格式:DOC 页数:4 大小:46.52KB
返回 下载 相关 举报
MATLAB应用技巧.doc_第1页
第1页 / 共4页
MATLAB应用技巧.doc_第2页
第2页 / 共4页
MATLAB应用技巧.doc_第3页
第3页 / 共4页
MATLAB应用技巧.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《MATLAB应用技巧.doc》由会员分享,可在线阅读,更多相关《MATLAB应用技巧.doc(4页珍藏版)》请在金锄头文库上搜索。

1、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)pr

2、ints 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 approxima

3、tion 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,

4、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 v

5、ersus 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, a

6、nd 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 d

7、raw 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

8、-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)ax

9、is 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 = 0;figure;for t=0:.01:10y=h-0.5*10*t2; %y为任意时刻小球离地的高度k=size(y);for i=1:kplot(x, y(i),ro);axis(-1, 1, 0, 500);M(:,i)=getframe;endendmovie(M,2,1)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号