科学计算科学计算 (24).pdf

上传人:奉*** 文档编号:67731163 上传时间:2022-12-26 格式:PDF 页数:25 大小:858.66KB
返回 下载 相关 举报
科学计算科学计算 (24).pdf_第1页
第1页 / 共25页
科学计算科学计算 (24).pdf_第2页
第2页 / 共25页
点击查看更多>>
资源描述

《科学计算科学计算 (24).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (24).pdf(25页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、2-D curves in other coordinatesData distribution plotsVector fields plots4 4.3 3 OtherOther 2 2-D D PlotsPlots1.21.2-D Curves in Other CoordinatesD Curves in Other Coordinatessemilogx(x1,y1,LineSpec1,x2,y2,LineSpec2,)semilogy(x1,y1,LineSpec1,x2,y2,LineSpec2,)loglog(x1,y1,LineSpec1,x2,y2,LineSpec2,)(

2、1)Logarithmic coordinates The semilogx function creates semilog plot,logarithmic scales for the x-axis whilelinear scales for the y-axis.The semilogy function also creates semilog plot,logarithmic scales for the y-axiswhile linear scales for the x-axis.The loglog function plots x-and y-coordinates u

3、sing logarithmic scales on the x-axis and the y-axis.Exammple 1 Plot 1in lineal and logarithmic scales coordinate system.x=0:0.1:10;y=1./x;subplot(2,2,1)plot(x,y)title(plot(x,y);grid onsubplot(2,2,2)semilogx(x,y)title(semilogx(x,y);grid onsubplot(2,2,3)semilogy(x,y)title(semilogy(x,y);grid onsubplot

4、(2,2,4)loglog(x,y)title(loglog(x,y);grid onArgument theta indicates the angle in radians and rho indicates the radius value for each point.Argument LineSpec is the same as that of the plot function.1.21.2-D Curves in Other CoordinatesD Curves in Other Coordinates(2)Polar plotpolar(theta,rho,LineSpec

5、)t=0:pi/100:2*pi;r=1-sin(t);subplot(1,2,1)polar(t,r)subplot(1,2,2)t1=t-pi/2;r1=1-sin(t1);polar(t,r1)Example 2 Plot a heart-shaped curve.=1 2.Data Distribution Plots2.Data Distribution PlotsBar plotHistogramPie chartScatter plot(1)Bar plot bar graphThe bar Function Create a vertical bar graphThe barh

6、 FunctionCreate a horizontal bar graph2.Data Distribution Plots2.Data Distribution Plots2.Data Distribution Plots2.Data Distribution Plots(1)Bar plot bar graphbar(y,style)Create a bar graph with one bar for each element in y.Argument style can be specified by one of these values.groupedDisplay each

7、group as adjacent bars that are centered around theircorresponding x value.stacked Display each group as one multicolored bar.The length of a bar is the sum ofthe elements in the group.y=1,2,3,4,5;1,2,1,2,1;5,4,3,2,1;subplot(1,2,1)bar(y)title(Group)subplot(1,2,2)bar(y,stacked)title(Stack)1 2 3 4 51

8、2 1 2 15 4 3 2 1Matrix YExample 3 Create a bar graph.2.Data Distribution Plots2.Data Distribution Plots(1)Bar plot bar graphbar(x,y,style)Specify x as a vector of unique values,and specify y as a matrix.The length of x must equal the length of at least one dimension of y.The other dimension of y con

9、tains values for the different series of bars.Example 4 The following table shows the household appliances sales data of a company in January 2015-2017.Draw a statistical graph with the data in the table.x=2015,2016,2017;y=68,80,115,98,102;75,88,102,99,110;81,86,125,105,115;bar(x,y)title(Group);2.Da

10、ta Distribution Plots2.Data Distribution Plots(1)Bar plot Histogram plotThe hist functionCreate a histogram plot in linear coordinate systemThe rose functionCreate a histogram plot in polar coordinate systemThe y is grouped into equally spaced bins between the minimum and maximum values of y.And the

11、 number of elements in the bin is computed,the height of each rectangle indicates the number of elements in the bin.Argument x is used to specify bin locations or categories.If x is a scalar,sorts y into the number of bins specified by x.If x is a vector,each element in vector x specifies each bin c

12、enter,and the length of the vector x is equal to the number of bins.2.Data Distribution Plots2.Data Distribution Plots(1)Bar plot Histogram plothist(y)hist(y,x)y=randn(500,1);subplot(2,1,1);hist(y);title(Histogram of Gaussian Distribution);subplot(2,1,2);x=-3:0.2:3;hist(y,x);title(Histogram of Inter

13、val Center Point)Example 5 Create a histogram of Gaussian distribution.2.Data Distribution Plots2.Data Distribution Plots(1)Bar plot Histogram plotrose(theta,x)Create a histogram plot in polar coordinates by sorting the values in theta into equally spaced bins.Specify the values in radians.Argument

14、x is used to specify the number of bins.y=randn(500,1);theta=y*pi;rose(theta)title(Histogram in Polar Scale)Example 6 Plot an angle histogram of Gaussian distribution in polar scale.(2)Area chartThe pie FunctionDraw pie chart The area FunctionCreate filled area 2-D plot2.Data Distribution Plots2.Dat

15、a Distribution Plots2.Data Distribution Plots2.Data Distribution Plots(2)Area chart The pie Functionpie(x,explode)Argument x stores the data to be plotted.The pie function offsets slices for the nonzero elements in the explode from the pie.Example 7 The number of excellent,good,medium,pass and fail

16、in an examination are 5,17,23,9,4 respectively.Make statistic analysis on an examination using pie chart.score=5,17,23,9,4;ex=0,0,0,0,1;pie(score,ex)legend(excellent,good,medium,pass,.fail,location,eastoutside)Note:The location option of the legend function sets the legend location.eastoutside posit

17、ions thelegend to the right of the axes.2.Data Distribution Plots2.Data Distribution Plots(3)Area chart The scatter function The stairs function The stem functionscatter(x,y,options,filled)Argument x and y are used to locate circles.Options is used to specify circle sizes,colors and the marker type.

18、If each marker have a face,you can use the filled option to fill the interior of the markers.When the option is omitted,the markers are hollow.(3)Discrete Data Plots scatter2.Data Distribution Plots2.Data Distribution PlotsExample 8 Draw a heart-shaped curve using scatter plot.The parameter equation

19、 of the curve is as follows:t=0:pi/50:2*pi;x=16*sin(t).3;y=13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t);scatter(x,y,rd,filled)=163=13 5cos(2)2cos(3)cos(4)3.Vector Fields Plots3.Vector Fields PlotsThe compass functionThe feather functionThe quiver functionThe quiver functionquiver(x,y,u,v)A quiver plot d

20、isplays velocity vectors as arrows with components(u,v)at the points(x,y).The matrices or vectors x,y,u,and v must all be the same size.If x and y are omitted,the vectors will be drawn at equally spaced points in the x-y plane.3.Vector Fields Plots3.Vector Fields PlotsA=4,5;B=-10,0;C=A+B;hold on;quiver(0,0,A(1),A(2);quiver(0,0,B(1),B(2);quiver(0,0,C(1),C(2);text(A(1),A(2),A);text(B(1),B(2),B);text(C(1),C(2),C);axis(-12,6,-1,6)grid onExample 9 Given vector A and vector B.Find A+B,and express it with vector plot.

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

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com