Function

Function - 消息

#1 已发布: 2012/1/24 02:15:46
Shiwani Thakur

Shiwani Thakur

0个赞,共7个帖子。

组: User

How to get spline in SMath? Which function can be used for spline?
cinterp function has only three in built arguments. Is it possible to add more arguments? If yes how to add?
#2 已发布: 2012/1/24 03:34:33
Radovan Omorjan

Radovan Omorjan

325个赞和1个踩,共2,052个帖子。

组: Moderator

Hello,

Look at this link splines, please.

Do not understand what additional arguments do you need, sorry.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 已发布: 2012/1/24 05:41:42
Shiwani Thakur

Shiwani Thakur

0个赞,共7个帖子。

组: User

Thanks Radovan.

Let me explain you my question with example

Suppose i have to write as shown below
K(x):= interp(c1,X,Y,x)

I can write it as
K(x):= interp(c1,X,Y)
but i am not able to add the last argument x. How can i add that in interp or cinterp function?


Regards,
Shiwani.
#4 已发布: 2012/1/24 09:50:55
Radovan Omorjan

Radovan Omorjan

325个赞和1个踩,共2,052个帖子。

组: Moderator

You are welcome Shiwani,

I hope you understand that those three spline functions use three arguments
1- vector - column matrix (independent var)
2- vector - column matrix (dependent var)
3- scalar - x-value

It will return y-value for the given x-value. Therefore, here is an example
[MATH=eng]X←mat(1,2,3,5,4,1)[/MATH] [MATH=eng]Y←mat(3,4,1,2,4,1)[/MATH]
For the value of X not given in the X vector provided Y vector, cubic spline will give
[MATH=eng]cinterp(X,Y,4)=0.1174[/MATH]

and you MUST define the function this way

[MATH=eng]K(X)←cinterp(X,Y,x)[/MATH]

If you need to pass some parameter to it, just make another function with more arguments (it may have the same name). I just made this up.

[MATH=eng]cinterp(X,Y,x,c)←line(cinterp(c/2*X,c*Y,x),1,1)[/MATH]
[MATH=eng]c←5[/MATH]
[MATH=eng]cinterp(X,Y,4,c)=20.8145[/MATH]

I hope this would help.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#5 已发布: 2012/1/27 05:37:45
Shiwani Thakur

Shiwani Thakur

0个赞,共7个帖子。

组: User

Thanks again. It is helpful.
  • 有新帖
  • 无新帖