科学计算科学计算 (29).pdf
《科学计算科学计算 (29).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (29).pdf(20页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Chapter 5 Data Analysis and Polynomial Chapter 5 Data Analysis and Polynomial EvaluationEvaluation5.1 Statistical Analysis of Data5.2 Polynomial Evaluation5.3 Data Interpolation5.4 Examples of Data Interpolation Application5.5 Curve Fitting5.6 Examples of Curve Fitting Application5.1 5.1 Statistical
2、 Analysis of DataStatistical Analysis of DataFind maximum and minimum elementsCalculate mean and median valuesCalculate sum and productCalculate cumulative sum and cumulative productCalculate standard deviation and correlation coefficientSort1.1.Find maximum and minimum elementsFind maximum and mini
3、mum elementsmax():Find the maximum element of a vector or matrix.min():Find the minimum element of a vector or matrix.When the argument is a vector,the function has two syntax:(1)y=max(X):Returns the maximum value of the vector X to y.If X contains plural elements,take the maximum value by module.(2
4、)y,k=max(X):Returns the maximum value of the vector X to y,the sequence number ofthe maximum element is stored in k.If X contains complex elements,the maximum value istaken by modulus.x=-43,72,9,16,23,47;y=max(x)y=72 y,k=max(x)y=72k=2Example 1:Find the maximum element of vector x,where x=-43,72,9,16
5、,23,47.Question:To find the maximum elements of the matrix by row,can it be done by onlyusing the first syntax?When the argument is a matrix,the function has three syntax:(1)max(A):Returns a row vector.The i-th element of the vector is the maximum valueof the i-th column ofA.(2)Y,U=max(A):Returns tw
6、o arguments which are used to record the maximumvalues for each column and the row number of the maximum element in each columnin matrix A.(3)max(A,dim):dim takes 1 or 2.When dim takes a value of 1,the function stilltakes the maximum value by column.When dim takes a value of 2,the function takesthe
7、maximum value by row,and the return is a column vector,whose i-th element is themaximum value of the i-th row ofA.A13567825632357825563101=Example 2:Find the maximum element of each row and column of matrix A and the maximum element of the entire matrix.Question:How can we get the maximum element of
8、 the entire matrix bycalling the max function only once?A=13,-56,78;25,63,-235;78,25,563;1,0,-1;max(A)ans=78 63 563 max(A,2)ans=78635631 max(max(A)ans=5632.Calculate 2.Calculate mean and median valuesmean and median valuesMean value:The mean value of the data series refers to the arithmetic average,
9、which is the sum of each item divided by the number of items.Median value:The median value is the value of the element which happens tobe in the middle in a sorted series.If the number of data is odd,take the value ofthe element whose position is in the middle.If the number of data is even,take thev
10、alue of the average of the two middle elements.In MATLAB,the functions for the mean and median values are:mean():Calculate the mean value.median():Calculate the median value.Question:With the mean,why do we need the median?x=1200,800,1500,1000,5000;mean(x)ans=1900 median(x)ans=1200Example 3:There ar
11、e five students in a dormitory.Their monthly cost of living is asshown in vector x.One of them,Xiao Ming,is from an ordinary family.What criterionis reasonable for him to ask his parents for the cost of living?x=1200,800,1500,1000,50003.Calculate3.Calculate sum and productsum and productsum():Sum fu
12、nction.prod():Product function.4.Calculate cumulative sum and cumulative product4.Calculate cumulative sum and cumulative productSuppose U is a vector.V and W are two vectors of the same length as U.Such two vectors are respectively called the cumulative sum vector and thecumulative product vector o
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 科学计算科学计算 29 科学 计算 29
限制150内