Filter löschen
Filter löschen

fitting a curve and adding values

4 Ansichten (letzte 30 Tage)
Matlabbey
Matlabbey am 21 Aug. 2012
hi all,
suppose i have the follo wing(i know it's linear but just for example of code)
x = [ 1 2 3 4 5];
i want to fit a spline through x and then use that to obtain twice as many values so that i would end up with 10 values in vector x. is that possible and how would that have impact on the data?
thank you!!

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 21 Aug. 2012
%you hav to specify x coordinate and y coordinate
x= [ 1 4 5 8 10]; y=sin(x) %for example
f=fit(x', y','smoothingspline')
%if
new_x=[1 2 3 4 5 6 7 8 9] %for example
new_y=f(new_x')
  2 Kommentare
Matlabbey
Matlabbey am 21 Aug. 2012
but what if i only have data values? would i just use 1,2,3,4 etc?
Azzi Abdelmalek
Azzi Abdelmalek am 21 Aug. 2012
ok if you have for example
y=rand(1,10) % data values
%then you must create x values
x=1:length(y)
f=fit(x', y','smoothingspline')
%then you can interpolate for
x1=[1 1.5 1.3 4.5 6.7];
y1=f(x1)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by