Am I using extrap wrong?
Show older comments
I'm trying to get extrap in linear, cubic, and spline methods. I have:
x = linspace(0, 4*pi) y = sin(x) c = 'yrbgk' ax = [0, 14, -2, 2]
axis(ax)
l = length(x)
o = l ./ 5
t = (2.*l)./5
th = (3.*l)./5
f = (4.*l)./5
fi = (5.*l)./5
cc = c(1)
cd = c(2)
ce = c(3)
cf = c(4)
cg = c(5)
omg = x(1:o)
zomg = x(1:t)
golly = x(1:th)
gee = x(1:f)
goshers = x(1:fi)
% all five pieces of data and colors
%first extrap
subplot(3,1,1)
yout = interp1(x, y, omg, 'linear', 'extrap')
youtu = interp1(x, y, zomg, 'linear', 'extrap')
youtub = interp1(x, y, golly, 'linear', 'extrap')
youtube = interp1(x, y, gee, 'linear', 'extrap')
plot(goshers,y,cg,gee,youtube,cf,golly,youtub,ce,zomg,youtu,cd,omg,yout,cc)
xlabel('x values')
ylabel('y values')
title('Interp1: Linear') My answer is supposed to look like this:

but mine looks like the black function with the color changing by range of x value. From 0 to 2 it is yellow, from 2 to 4 it is red, 4 to 6 is blue, 6 to 8 is green and 8 to 10 is black
Accepted Answer
More Answers (0)
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!