sub2ind gives error: Error using sub2ind (line 43) Out of range subscript.
Show older comments
Below is a script (not my own, but I have been modifying it to run on a specific data set) that gives me an error in the final line: Error using sub2ind (line 43) Out of range subscript.
I am not sure how to solve this. I have tried:
k=find(~ys') and k=find(~xs')
to find where there are potential indicies of zero value. From these I get the output:
k = 0×1 empty double column vector
Any help would be greatly appreciated.
src1 = [-12579.27069; 4262.64531]
rec1 = [-12814.28064; 4874.32785]
mult=10
ds = checkerboard(10,50,57) > 0.5;
ds = padarray(ds,[2,2]); % shifted checkerboard
ds = (ds(:,:)-0.5)/5;
sTrue = ds+0.4;
sc=size(sTrue);
lc=length(sTrue(:));
steps = ceil(1.5*max(sc));
av=single([]);
ii=single([]);
jj=single([]);
v0 = rec1-src1;
vn = norm(v0);
v = v0/vn;
points = src1+v*linspace(0,steps,steps*mult);
pcheck = sum((points-rec1).^2);
[u,i]=min(pcheck);
inds = floor(points(:,2:i));
npoints=length(inds);
xs=inds(1,:);
ys=inds(2,:);
ds_int = (vn/npoints);
indA = sub2ind(sc,ys',xs');
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!