Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2008-03-15, 21:06   #1
chenrenhuang
初级会员
 
注册日期: 2008-01-14
年龄: 42
帖子: 10
声望力: 18
chenrenhuang 正向着好的方向发展
灯泡 【求助】高手指点!!

是否能进行符号插值计算呢?比如说x=(1 2 3),y=(a b c),问当x=2.5的时候,y应该为多少呢?能用a、b、c来插值表示不?应该要怎样编写程序呢?这个问题困扰我好久,请高手指点一二,谢谢了!
chenrenhuang 当前离线   回复时引用此帖
旧 2008-03-18, 16:12   #2
tolabfans
普通会员
 
注册日期: 2008-02-29
年龄: 44
帖子: 92
声望力: 19
tolabfans 正向着好的方向发展
默认

引用:
作者: chenrenhuang 查看帖子
是否能进行符号插值计算呢?比如说x=(1 2 3),y=(a b c),问当x=2.5的时候,y应该为多少呢?能用a、b、c来插值表示不?应该要怎样编写程序呢?这个问题困扰我好久,请高手指点一二,谢谢了!
我不是高手,斗胆提点看法。能否让matlab自动作出x,y的曲线图,这样中间就自动有插值了。
tolabfans 当前离线   回复时引用此帖
旧 2008-03-19, 15:07   #3
guanshuai
初级会员
 
注册日期: 2008-03-19
年龄: 37
帖子: 10
声望力: 18
guanshuai 正向着好的方向发展
默认

可以用interp1命令来进行插值,具体的可以看一下matlab的help文件,我把其中的内容写在下面了

help interp1
INTERP1 1-D interpolation (table lookup)
YI = INTERP1(X,Y,XI) interpolates to find YI, the values of the
underlying function Y at the points in the array XI. X must be a
vector of length N.
If Y is a vector, then it must also have length N, and YI is the
same size as XI. If Y is an array of size [N,D1,D2,...,Dk], then
the interpolation is performed for each D1-by-D2-by-...-Dk value
in Y(i,:,:,...,.
If XI is a vector of length M, then YI has size [M,D1,D2,...,Dk].
If XI is an array of size [M1,M2,...,Mj], then YI is of size
[M1,M2,...,Mj,D1,D2,...,Dk].

YI = INTERP1(Y,XI) assumes X = 1:N, where N is LENGTH(Y)
for vector Y or SIZE(Y,1) for array Y.

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 location, returns
values YI interpolated within the elements of Y.

YI = INTERP1(X,Y,XI,METHOD) specifies alternate methods.
The default is linear interpolation. Use an empty matrix [] to specify
the default. Available methods are:

'nearest' - nearest neighbor interpolation
'linear' - linear interpolation
'spline' - piecewise cubic spline interpolation (SPLINE)
'pchip' - shape-preserving piecewise cubic interpolation
'cubic' - same as 'pchip'
'v5cubic' - the cubic interpolation from MATLAB 5, which does not
extrapolate and uses 'spline' if X is not equally
spaced.

YI = INTERP1(X,Y,XI,METHOD,'extrap') uses the specified method for
extrapolation for any elements of XI outside the interval spanned by X.
Alternatively, YI = INTERP1(X,Y,XI,METHOD,EXTRAPVAL) replaces
the values outside of the interval spanned by X with EXTRAPVAL.
NaN and 0 are often used for EXTRAPVAL. The default extrapolation
behavior with four input arguments is 'extrap' for 'spline' and 'pchip'
and EXTRAPVAL = NaN for the other methods.

PP = INTERP1(X,Y,METHOD,'pp') will use the specified method to
generate the ppform (piecewise polynomial form) of Y. The method may be
any of the above except for 'v5cubic'. PP may then be evaluated via
PPVAL. PPVAL(PP,XI) is the same as INTERP1(X,Y,XI,METHOD,'extrap').

For example, generate a coarse sine curve and interpolate over a
finer abscissa:
x = 0:10; y = sin(x); xi = 0:.25:10;
yi = interp1(x,y,xi); plot(x,y,'o',xi,yi)

For a multi-dimensional example, we construct a table of functional
values:
x = [1:10]'; y = [ x.^2, x.^3, x.^4 ];
xi = [ 1.5, 1.75; 7.5, 7.75]; yi = interp1(x,y,xi);

creates 2-by-2 matrices of interpolated function values, one matrix for
each of the 3 functions. yi will be of size 2-by-2-by-3.

Class support for inputs X, Y, XI, EXTRAPVAL:
float: double, single

See also interp1q, interpft, spline, pchip, interp2, interp3, interpn, ppval.


Reference page in Help browser
doc interp1
guanshuai 当前离线   回复时引用此帖
旧 2008-03-20, 15:46   #4
chenrenhuang
初级会员
 
注册日期: 2008-01-14
年龄: 42
帖子: 10
声望力: 18
chenrenhuang 正向着好的方向发展
默认

嗯, 现在y值不清楚,只是符号表示,是未知的,因而要作出图象似乎不现实!
chenrenhuang 当前离线   回复时引用此帖
旧 2008-03-20, 15:55   #5
chenrenhuang
初级会员
 
注册日期: 2008-01-14
年龄: 42
帖子: 10
声望力: 18
chenrenhuang 正向着好的方向发展
默认

引用:
作者: guanshuai 查看帖子
可以用interp1命令来进行插值,具体的可以看一下matlab的help文件,我把其中的内容写在下面了

help interp1
INTERP1 1-D interpolation (table lookup)
YI = INTERP1(X,Y,XI) interpolate...

谢谢这位兄弟的提示。只是似乎interp和polyfit插值都是针对具体的数值才能给出答案,而对于符号的输入如上面提到的(a、b、c)不能进行求解,总是提示错误的表述,请问如何才能在输入符号表述时也能正确的运算呢 ?
chenrenhuang 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 17:19


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.