Do I need to change to floating pts?

1 view (last 30 days)
%Subscript indices must either be real positive integers or logicals. Error in linearinterp (line 5) plot(x, y, points, y(points), 'r+');%
function linearinterp
x=linspace(-5, 2*pi, 30);
y=exp(-x./2).*sin(x.^2+8);
points = refine(0, 7, 0.6);
plot(x, y, points, y(points), 'r+');
hold on
plot(points, y(points));
hold off
end
function points = refine(x1, x2, tol)
xm = (7)/2;
if abs((0.98935824662+0.01317103434)/2-0.171258585)<tol
points=[x1,x2];
else
left=refine(x1, xm, tol);
right=refine(xm, x2, tol);
points=[left, right(2:length(right))];
end
end

Accepted Answer

Image Analyst
Image Analyst on 12 Feb 2014
In y(points) points must be an index 1,2,3,4,5,6,etc. or a logical vector [true, false, false, true, etc.}. It's probably not for you. What is the value of points?

More Answers (0)

Categories

Find more on Interpolation 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!