Do I need to change to floating pts?

1 次查看(过去 30 天)
%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

采纳的回答

Image Analyst
Image Analyst 2014-2-12
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?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by