nick1256
nick1256

Reputation: 31

Interpolating data points in Curve Fitting Tool in Matlab 2017

I have a set of 13 experimental points with X ranging from 0 to 100 in unequal intervals and corresponding values of Y. Using curve fitting tool (Interpolant, PCHIP) I can get a graph and also get values of intermittent points using data cursor. However I need 1000 values spaced at an equal interval of 0.1 from 0 to 100. How can I get these 1000 values from the tool? There used to be an 'evaluate' option in older matlab, but I do not see that in this one.

Upvotes: 2

Views: 118

Answers (2)

Laure
Laure

Reputation: 373

Here's how to get the equally-spaced interpolation data in the script:

% Your data
x = [0;4;6;10;11;13;17;23;24;34;35;37;39;40;49;58;78;82;90;94;100];
y = sin([0.51;1.15;1.19;1.86;1.92;2.32;2.74;2.81;2.83;3.44;3.93;...
     4.07;4.08;4.32;4.6;4.68;4.87;4.9;4.99;5.14;5.84]*3);

% Create new equally-distant baseline
x2 = linspace(0,100,1000); 

% Fit your data, compute new values of y for x2
y2 = pchip(x,y,x2);

% Plot everything
figure
hold all
plot(x,y,'kx')
plot(x2,y2,'r-');

Upvotes: 0

nick1256
nick1256

Reputation: 31

Found out the option to save the fitted results to workspace. After that it was pretty easy. x1 = (0:0.1:100).'; y1 = fittedcurve (x1);

Now I feel very stupid.

Upvotes: 1

Related Questions