How do I add any point to a piecewise fplot?

Multi tool use
up vote
0
down vote
favorite
I have been tasked with finding the natural cubic spline function S to interpolate a set of data I have been given. I have been given 11 data points. Essentially what this means is that I must place a cubic function between these points so that I have 10 cubic functions that flow together into something that looks like 1 function.
I have already completed this. I am new to using MatLab, so I'm not sure how I am supposed to put points on this plot.
Due to the nature of there being 10 functions I must glue together, I found a function called piecewise that works well for this. Here is how I define the function that is piecewise:
syms S(t)
S(t) = piecewise(x(1)<t<x(2), (longExpression1), x(2)<t<x(3), (longExpression2), ... x(10)<t<x(11), (longExpression10));
I then plot the function with fplot() and define the domain I want to see the plot for:
fplot(S(t), [0,100]);
I need to plot 13 points on this graph.
The first 11 points that I need to plot are the points that lie at the ends of each of these segments. The last 2 points that I need plot are not endpoints, but instead are points somewhere in the middle of two different piecewise segments.
The 11 data points have the following x and y values:
x = [0 10 20 30 40 50 60 70 80 90 100];
y = [75.995 91.972 105.711 123.203 131.669 150.697 179.323 203.212 226.505 249.633 281.422];
My plot looks like this:
matlab matlab-figure
add a comment |
up vote
0
down vote
favorite
I have been tasked with finding the natural cubic spline function S to interpolate a set of data I have been given. I have been given 11 data points. Essentially what this means is that I must place a cubic function between these points so that I have 10 cubic functions that flow together into something that looks like 1 function.
I have already completed this. I am new to using MatLab, so I'm not sure how I am supposed to put points on this plot.
Due to the nature of there being 10 functions I must glue together, I found a function called piecewise that works well for this. Here is how I define the function that is piecewise:
syms S(t)
S(t) = piecewise(x(1)<t<x(2), (longExpression1), x(2)<t<x(3), (longExpression2), ... x(10)<t<x(11), (longExpression10));
I then plot the function with fplot() and define the domain I want to see the plot for:
fplot(S(t), [0,100]);
I need to plot 13 points on this graph.
The first 11 points that I need to plot are the points that lie at the ends of each of these segments. The last 2 points that I need plot are not endpoints, but instead are points somewhere in the middle of two different piecewise segments.
The 11 data points have the following x and y values:
x = [0 10 20 30 40 50 60 70 80 90 100];
y = [75.995 91.972 105.711 123.203 131.669 150.697 179.323 203.212 226.505 249.633 281.422];
My plot looks like this:
matlab matlab-figure
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have been tasked with finding the natural cubic spline function S to interpolate a set of data I have been given. I have been given 11 data points. Essentially what this means is that I must place a cubic function between these points so that I have 10 cubic functions that flow together into something that looks like 1 function.
I have already completed this. I am new to using MatLab, so I'm not sure how I am supposed to put points on this plot.
Due to the nature of there being 10 functions I must glue together, I found a function called piecewise that works well for this. Here is how I define the function that is piecewise:
syms S(t)
S(t) = piecewise(x(1)<t<x(2), (longExpression1), x(2)<t<x(3), (longExpression2), ... x(10)<t<x(11), (longExpression10));
I then plot the function with fplot() and define the domain I want to see the plot for:
fplot(S(t), [0,100]);
I need to plot 13 points on this graph.
The first 11 points that I need to plot are the points that lie at the ends of each of these segments. The last 2 points that I need plot are not endpoints, but instead are points somewhere in the middle of two different piecewise segments.
The 11 data points have the following x and y values:
x = [0 10 20 30 40 50 60 70 80 90 100];
y = [75.995 91.972 105.711 123.203 131.669 150.697 179.323 203.212 226.505 249.633 281.422];
My plot looks like this:
matlab matlab-figure
I have been tasked with finding the natural cubic spline function S to interpolate a set of data I have been given. I have been given 11 data points. Essentially what this means is that I must place a cubic function between these points so that I have 10 cubic functions that flow together into something that looks like 1 function.
I have already completed this. I am new to using MatLab, so I'm not sure how I am supposed to put points on this plot.
Due to the nature of there being 10 functions I must glue together, I found a function called piecewise that works well for this. Here is how I define the function that is piecewise:
syms S(t)
S(t) = piecewise(x(1)<t<x(2), (longExpression1), x(2)<t<x(3), (longExpression2), ... x(10)<t<x(11), (longExpression10));
I then plot the function with fplot() and define the domain I want to see the plot for:
fplot(S(t), [0,100]);
I need to plot 13 points on this graph.
The first 11 points that I need to plot are the points that lie at the ends of each of these segments. The last 2 points that I need plot are not endpoints, but instead are points somewhere in the middle of two different piecewise segments.
The 11 data points have the following x and y values:
x = [0 10 20 30 40 50 60 70 80 90 100];
y = [75.995 91.972 105.711 123.203 131.669 150.697 179.323 203.212 226.505 249.633 281.422];
My plot looks like this:
matlab matlab-figure
matlab matlab-figure
asked Nov 9 at 23:55
FlamePrinz
859
859
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You may try the following:
fplot(S(t), [0,100]);
hold on % This will prevent the new plot from erasing the result of fplot
plot(x,y,'or'); % 'ok' is a format identifier, the points will be plot as red(r) circles(o)
plot([x1,X2],[S(x1),S(x2)],'or'); %Plot the two extra points
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You may try the following:
fplot(S(t), [0,100]);
hold on % This will prevent the new plot from erasing the result of fplot
plot(x,y,'or'); % 'ok' is a format identifier, the points will be plot as red(r) circles(o)
plot([x1,X2],[S(x1),S(x2)],'or'); %Plot the two extra points
add a comment |
up vote
1
down vote
accepted
You may try the following:
fplot(S(t), [0,100]);
hold on % This will prevent the new plot from erasing the result of fplot
plot(x,y,'or'); % 'ok' is a format identifier, the points will be plot as red(r) circles(o)
plot([x1,X2],[S(x1),S(x2)],'or'); %Plot the two extra points
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You may try the following:
fplot(S(t), [0,100]);
hold on % This will prevent the new plot from erasing the result of fplot
plot(x,y,'or'); % 'ok' is a format identifier, the points will be plot as red(r) circles(o)
plot([x1,X2],[S(x1),S(x2)],'or'); %Plot the two extra points
You may try the following:
fplot(S(t), [0,100]);
hold on % This will prevent the new plot from erasing the result of fplot
plot(x,y,'or'); % 'ok' is a format identifier, the points will be plot as red(r) circles(o)
plot([x1,X2],[S(x1),S(x2)],'or'); %Plot the two extra points
answered Nov 10 at 0:27
Brice
1,08810
1,08810
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234753%2fhow-do-i-add-any-point-to-a-piecewise-fplot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
DsRkgVYSlZq8VgYD,n 48gsiWgFCf wQ3ZMsFgYmUo8SCH1YzyULDUBMIBBfK,scLpkh g