MATLAB: Check if an array is equispaced arrayequispaced I am given a vector of numbers and I have to check if this vector has its samples equispaced or not. How can I do it without using fors? Best Answer Something like thisx = [1 2 3];dx = diff(x);is_equidistant = all(dx==dx(1));Result>> is_equidistantis_equidistant = logical 1Ifx = [1 2 5];dx = diff(x);is_equidistant = all(dx==dx(1));Result>> is_equidistantis_equidistant = logical 0If you want to check it with a tolerance valuex = [1 2 3.00000000000001];dx = diff(x);is_equidistant = all(ismembertol(dx, dx(1)));Result>> is_equidistantis_equidistant = logical 1
Best Answer