# How to do symbolic interpolation in matlab?

22 ビュー (過去 30 日間)
Mohammad Shojaei Arani 2021 年 11 月 12 日

Hellow friends!
I need to do symbolic interpolation in matlab but after spending a day I had no success. You might say
why I do not use function handle. The reason is that I need to perform a lot of differentiations with this
spline interpolant which is not possible with function handles. For simplicity, consider this 1D interpolation
problem: Assume that x=1:5 but my y-Data are symbolic as bellow:
x=1:5;
y=sym('y', [1 5]);
pp=spline(x,y);
Also, something like the following would be suitable for me but it also does not work:
syms x f(x)
x1=1:5;
f(x)=@(y)spline(x1,y,x);
Any idea?

サインインしてコメントする。

### 回答 (1 件)

John D'Errico 2022 年 1 月 11 日

You cannot define a symbolic spline. At least not in MATLAB. Could you write such a code? Well, yes. But you would need to understand splines well enough to write the code yourself. Functions like spline or even interp1 are not designed to accept symbolic input. Sorry, but they are not, nor do I know of one in MATLAB that can do so. (Could I write it? Certainly yes. But I won't.)
As for what you want to do that you could not do, this we do not really know, only that you did not know how to do what you need to do. Just wanting to do many interpolations is not that hard, so your real problem may just be in how to structure your code to be efficient. We don't know what the real issue is, only what you think to be the issue.

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by