can i make a symbolic function without a specific formula?

If I have data in two vectors which represents x and y for any experiment and I want to make a symbolic function that can represent y as a function of x but i have no specific formula for y just the measurements between x and y . How i can do that is there any code for that other than interpolation??

回答 (2 件)

Cris LaPierre
Cris LaPierre 2018 年 11 月 14 日

0 投票

I'm not sure interpolation would help you. My approach would be to visualize the data and then decide what type of equation to fit the data to.
Walter Roberson
Walter Roberson 2018 年 11 月 14 日

0 投票

syms XX
tt = num2cell( [XX == x(:),y(:)].' );
ff(XX) = piecewise(tt{:});
Now if I got everything right then ff should be a symbolic function such that if you input one of the values from x then it should return the corresponding value for y. For all other values it should return sym(nan)
This is not likely to be a useful function, but I guess you have your reasons for wanting it.

3 件のコメント

ghghgh
ghghgh 2018 年 11 月 15 日
thanks for your reply but that is not what i want
if
syms XX
x=[1 2 3];
y=[10 5 6];
tt = num2cell( [XX == x(:),y(:)].' );
ff(XX) = piecewise(tt{:});
i want to make a continous relation between x and y by making y as a function of x at any other time so i can for example find y at x=2.5
i know curve fitting may do that but i look for another method with matlab
using the previous code x(2.5) gives NaN but i want to make a continous relation based on discrete relations known for x and y can you help in this point plz??
ghghgh
ghghgh 2018 年 11 月 15 日
i mean ff(2.5) will give NaN i want to use ff as a function can be used to find any y related to any x depending on the relations (measurements) gave for vectors x and y ??
Walter Roberson
Walter Roberson 2018 年 11 月 15 日
No, you are mistaken . You do want NaN for ff(2.5) You were quite clear in your original question ,
How i can do that is there any code for that other than interpolation??
Interpolation is the word that covers all possible techniques for forecasting intermediate values based upon known values . When you said "other than interpolation" then you indicated that absolutely no forecasting was to be permitted, that the function should only ever return the values already known and never ever any other value . And that is what my code does for you .

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

質問済み:

2018 年 11 月 14 日

コメント済み:

2018 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by