Filter löschen
Filter löschen

Interpolating through spline and then get corresponding values

2 Ansichten (letzte 30 Tage)
Hello, I have a certain set of points which create a curve. I want to evaluate what is the y value at other x locations, not given in the problem.
Unfortunately, there is no polynomial which can passes though all these points correctly.
I am sure other people might have asked this question, but I could not find anything.
The X values are:
if true
% code
x=[0
0.00420000000000000
0.00800000000000000
0.0125000000000000
0.0177000000000000
0.0236000000000000
0.0305000000000000
0.0385000000000000
0.0476000000000000
0.0581000000000000
0.0701000000000000
0.0838000000000000
0.0993000000000000
0.116700000000000
0.136300000000000
0.158200000000000
0.182500000000000
0.209200000000000
0.238400000000000
0.269800000000000
0.303600000000000
0.339300000000000
0.376800000000000
0.415600000000000
0.455300000000000
0.495400000000000
0.535600000000000
0.575100000000000
0.613700000000000
0.650900000000000
0.686200000000000
0.719500000000000
0.750500000000000
0.779200000000000
0.805400000000000
0.829200000000000
0.850600000000000
0.869800000000000
0.886900000000000
0.902000000000000
0.915300000000000
0.927000000000000
0.937200000000000
0.946100000000000
0.953900000000000
0.960600000000000
0.965400000000000
0.970400000000000
0.975400000000000
0.980200000000000
0.985200000000000
0.990200000000000
0.995100000000000
1];
end
The y values are:
if true
% code
y=[0.127489040000000
0.111766040000000
0.0167797700000000
0.0337462690000000
0.0266396250000000
0.111117580000000
0.130855270000000
0.138929860000000
0.163963910000000
0.134142850000000
0.150978780000000
0.151461170000000
0.142033560000000
0.143054720000000
0.142033560000000
0.139969710000000
0.139452300000000
0.138929860000000
0.137879260000000
0.141520320000000
0.143562680000000
0.146571800000000
0.159900150000000
0.167058910000000
0.178109250000000
0.196599630000000
0.216707350000000
0.225149480000000
0.251330640000000
0.286469960000000
0.304243410000000
0.330819300000000
0.359129760000000
0.389805860000000
0.429068680000000
0.448364490000000
0.485802150000000
0.531624250000000
0.547334130000000
0.565165850000000
0.582247920000000
0.598792800000000
0.619664680000000
0.639333560000000
0.638537430000000
0.668565600000000
0.713292490000000
0.687499690000000
0.660858750000000
0.633757700000000
0.628645890000000
0.672958870000000
0.660858750000000
0.623358350000000];
end
And the values where I want to evaluate are:
if true
% code
xnew=[0.0250000000000000
0.0500000000000000
0.0750000000000000
0.100000000000000
0.150000000000000
0.200000000000000
0.300000000000000
0.400000000000000
0.500000000000000
0.600000000000000
0.700000000000000
0.800000000000000
0.900000000000000
0.950000000000000];
end
The way I would do is by linear interpolation through the different points and then get for each interval the coefficients of the polynomial and input my data and check if they are within certain limits and use poleval. I think this way is a bit long, and it might be possible to fit a spline or other manners.
Thanks a lot for any suggestions.
Antonio

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 12 Sep. 2012
Bearbeitet: Azzi Abdelmalek am 12 Sep. 2012
method='linear'
ynew=interp1(x,y,xnew,method)
%or
method='smoothingspline'
f=fit(x,y,method);
ynew=f(xnew)
  1 Kommentar
mortain
mortain am 12 Sep. 2012
Bearbeitet: mortain am 12 Sep. 2012
Thanks a lot, I was sure there was an easy manner....two lines :-)! Apparently the linear matches better.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by