MATLAB处理matlab中interp1函数数出错

interp1 (MATLAB Functions)
One-dimensional data interpolation (table lookup)
yi = interp1(x,Y,xi)
yi = interp1(Y,xi)
yi = interp1(x,Y,xi,method)
yi = interp1(x,Y,xi,method,'extrap')
yi = interp1(x,Y,xi,method,extrapval)
pp = interp1(x,Y,method,'pp')
Description
yi = interp1(x,Y,xi) interpolates to find yi, the values of the underlying function Y at the points in the vector or array xi. x must be a vector. Y can be a scalar, a vector, or an array of any dimension, subject to the following conditions:
If Y is a scalar or vector, it must have the same length as x. A scalar value for x or Y is expanded to have the same length as the other. xi can be a scalar, a vector, or a multidimensional array, and yi has the same size as xi.
If Y is an array that is not a vector, the size of Y must have the form [n,d1,d2,...,dk], where n is the length of x. The interpolation is performed for each d1-by-d2-by-...-dk value in Y. The sizes of xi and yi are related as follows:
If xi is a scalar or vector, size(yi) equals [length(xi), d1, d2, ..., dk].
If xi is an array of size [m1,m2,...,mj], yi has size [m1,m2,...,mj,d1,d2,...,dk].
yi = interp1(Y,xi)
assumes that x = 1:N, where N is the length of Y for vector Y, or size(Y,1) for matrix Y.
yi = interp1(x,Y,xi,method)
interpolates using alternative methods:
Nearest neighbor interpolation
Linear interpolation (default)
Cubic spline interpolation
Piecewise cubic Hermite interpolation
(Same as 'pchip')
Cubic interpolation used in MATLAB 5
For the 'nearest', 'linear', and 'v5cubic' methods, interp1(x,Y,xi,method) returns NaN for any element of xi that is outside the interval spanned by x. For all other methods, interp1 performs extrapolation for out of range values.
yi = interp1(x,Y,xi,method,'extrap')
uses the specified method to perform extrapolation for out of range values.
yi = interp1(x,Y,xi,method,extrapval)
returns the scalar extrapval for out of range values. NaN and 0 are often used for extrapval.
pp = interp1(x,Y,method,'pp') uses the specified method to generate the piecewise polynomial form (ppform) of Y. You can use any of the methods in the preceding table, except for 'v5cubic'.
The interp1 command interpolates between data points. It finds values at intermediate points, of a one-dimensional function
that underlies the data. This function is shown below, along with the relationship between vectors x, Y, xi, and yi.
Interpolation is the same operation as table lookup. Described in table lookup terms, the table is [x,Y] and interp1 looks up the elements of xi in x, and, based upon their locations, returns values yi interpolated within the elements of Y.
interp1q is quicker than interp1 on non-uniformly spaced data because it does no input checking. For interp1q to work properly, x must be a monotonically increasing column vector and Y must be a column vector or matrix with length(X) rows. Type help interp1q at the command line for more information.
Example 1. Generate a coarse sine curve and interpolate over a finer abscissa.
y = sin(x);
xi = 0:.25:10;
yi = interp1(x,y,xi);
plot(x,y,'o',xi,yi)
Example 2. The following multidimensional example creates 2-by-2 matrices of interpolated function values, one matrix for each of the three functions x2, x3, and x4.
x = [1:10]'; y = [ x.^2, x.^3, x.^4 ];
xi = [1.5, 1.75; 7.5, 7.75];
yi = interp1(x,y,xi);
The result yi has size 2-by-2-by-3.
Example 3. Here are two vectors representing the census years from 1900 to 1990 and the corresponding United States population in millions of people.
p = [75.995
131.669...
The expression interp1(t,p,1975) interpolates within the census data to estimate the population in 1975. The result is
Now interpolate within the data at every year from 1900 to 2000, and plot the result.
y = interp1(t,p,x,'spline');
plot(t,p,'o',x,y)
Sometimes it is more convenient to think of interpolation in table lookup terms, where the data are stored in a single table. If a portion of the census data is stored in a single 5-by-2 table,
then the population in 1975, obtained by table lookup within the matrix tab, is
p = interp1(tab(:,1),tab(:,2),1975)
Example 4. The following example uses the 'cubic' method to generate the piecewise polynomial form (ppform) of Y, and then evaluates the result using ppval.
x = 0:.2: y = sin(x);
pp = interp1(x,y,'cubic','pp');
xi = 0:.1:
yi = ppval(pp,xi);
plot(x,y,'ko'), hold on, plot(xi,yi,'r:'), hold off
The interp1 command is a MATLAB M-file. The 'nearest' and 'linear' methods have straightforward implementations.
For the 'spline' method, interp1 calls a function spline that uses the functions ppval, mkpp, and unmkpp. These routines form a small suite of functions for working with piecewise polynomials. spline uses them to perform the cubic spline interpolation. For access to more advanced features, see the spline reference page, the M-file help for these functions, and the .
For the 'pchip' and 'cubic' methods, interp1 calls a function pchip that performs piecewise cubic interpolation within the vectors x and y. This method preserves monotonicity and the shape of the data. See the pchip reference page for more information.
References
[1] &de Boor, C., A Practical Guide to Splines, Springer-Verlag, 1978.
&&int8, int16, int32, int64&interp2&
The MathWorks, Inc.君,已阅读到文档的结尾了呢~~
matlab interp1 matlab 曲线拟合 matlab 拟合 matlab线性拟合 matlab数据拟合 matlab 拟合函数 matlab拟合工具箱 matlab多项式拟合 matlab 直线拟合 matlab曲线拟合函数
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
Matlab一维插值interp1例子及可视拟合界面
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口matlab再带的插值函数interp1的四种插值方法
matlab再带的插值函数interp1的四种插值方法
xx=0:0.5:2*
%interp1对sin函数进行分段线性插值,调用interp1的时候,默认的是分段线性插值
y1=interp1(x,y,xx);
plot(x,y,'o',xx,y1,'r')
title('分段线性插值')
y2=interp1(x,y,xx,'nearest');
plot(x,y,'o',xx,y2,'r');
title('临近插值')
%球面线性插值
y3=interp1(x,y,xx,'spline');
plot(x,y,'o',xx,y3,'r')
title('球面插值')
%三次多项式插值法
y4=interp1(x,y,xx,'cubic');
plot(x,y,'o',xx,y4,'r');
title('三次多项式插值')
(1)&&&&Nearest方法速度最快,占用内存最小,但一般来说误差最大,插值结果最不光滑。
(2)&&&&Spline三次样条插值是所有插值方法中运行耗时最长的,插值函数及其一二阶导函数都连续,是最光滑的插值方法。占用内存比cubic方法小,但是已知数据分布不均匀的时候可能出现异常结果。
(3)&&&&Cubic三次多项式插值法中,插值函数及其一阶导数都是连续的,所以插值结果比较光滑,速度比Spline快,但是占用内存最多。
y=interp1(x,Y,xi)
由已知点集(x,Y)插值计算xi上的函数值
y=interp1(x,Y,xi)
相当于x=1:length(Y)的interp(x,Y,xi)
y=interp1(x,Y,xi,method)
用指定插值方法计算插值点xi上的函数值
y=interp1(x,Y,xi,method,’extrap’)
对xi中超出已知点集的插值点用指定插值方法计算函数值
y=interp1(x,Y,xi,method,’extrap’,extrapval)
用指定方法插值xi上的函数值,超出已知点集处函数值取extrapval
y=interp1(x,Y,xi,method,’pp’)
用指定方法插值,但返回结果为分段多项式
‘nearest’
最邻近插值:插值点处函数值与插值点最邻近的已知点函数值
分段线性插值:插值点处函数值由连接其最邻近的两侧点的线性函数预测。Matlab中interp1的默认方法。
‘spline’
样条插值:默认为三次样条插值。可用spline函数替代
三次Hermite多项式插值,可用pchip函数替代
同’pchip’,三次Hermite多项式插值
版权声明:欢迎大家一起交流,有错误谢谢指正~~~
感谢关注 Ithao123精品文库频道,是专门为互联网人打造的学习交流平台,全面满足互联网人工作与学习需求,更多互联网资讯尽在 IThao123!
Laravel是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。
Hadoop是一个由Apache基金会所开发的分布式系统基础架构。
用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。
Hadoop实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS。HDFS有高容错性的特点,并且设计用来部署在低廉的(low-cost)硬件上;而且它提供高吞吐量(high throughput)来访问应用程序的数据,适合那些有着超大数据集(large data set)的应用程序。HDFS放宽了(relax)POSIX的要求,可以以流的形式访问(streaming access)文件系统中的数据。
Hadoop的框架最核心的设计就是:HDFS和MapReduce。HDFS为海量的数据提供了存储,则MapReduce为海量的数据提供了计算。
产品设计是互联网产品经理的核心能力,一个好的产品经理一定在产品设计方面有扎实的功底,本专题将从互联网产品设计的几个方面谈谈产品设计
随着国内互联网的发展,产品经理岗位需求大幅增加,在国内,从事产品工作的大部分岗位为产品经理,其实现实中,很多从事产品工作的岗位是不能称为产品经理,主要原因是对产品经理的职责不明确,那产品经理的职责有哪些,本专题将详细介绍产品经理的主要职责
IThao123周刊> 对不起!您查找的页面在火星,地球暂时无法访问
内部服务器错误(Internal Server Error)
秒之后页面自动跳转,您可以:
2) 去其他地方逛逛:   

我要回帖

更多关于 matlab中interp2函数 的文章

 

随机推荐