I am trying to connect six Data points in a way as I would do it intuitively by hand. The regular plot
command gives me a very jagged line because it's only six data points. The spline
command gets close to were I want to be. However it continues to fit the line before and after. I however would like for it to start with the first data point and to end with the last. Further I would like to avoid the bump shown in the picture attached. For this I would need a higher order polynomial I'd assume.
Can someone help me to connect those data points as one would do it manually? It does not need to be done via the spline
command.
Minimal Example:
clear all, close all, clc
%% Minimal Example
%% Data
x = 2:7;
y = [69, 27, 3, 0.5, 0, 0]
%% Using Regular Plot
plot(x,y)
%% Using Spline
hold on
xx = 0:.25:10;
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)
For stopping the spline at the desired beginning and ending I had edit
xx = 2:.25:7
to the desired boundaries 2 to 7. I oversaw that option.In order to get rid of the bump I edited
yy
with the followingfor-loop
. This does the job for me right now.I'd still be thankful if someone knows how to just connect data points with a more curvy line. Thank you!