[Index for tmp_for_tar/vrml.doc]
[Return to Master Index]
ind2sub
(tmp_for_tar/vrml.doc/ind2sub.m)
Function Synopsis
ii = ind2sub(sz,r,c)
Help text
i = ind2sub(sz,r,c) = ind2sub(sz,[r,c])
i is the indice of element (r,c) in a matrix of size sz. That is,
i=(c-1)*sz(1)+r
See also sub2ind.
Last modified: January 2000
Listing of function file tmp_for_tar/vrml.doc/ind2sub.m
## i = ind2sub(sz,r,c) = ind2sub(sz,[r,c])
##
## i is the indice of element (r,c) in a matrix of size sz. That is,
## i=(c-1)*sz(1)+r
##
## See also sub2ind.
##
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: January 2000
function ii = ind2sub(sz,r,c)
if nargin==2,
if size(r,2)==2, # Assume it's [r,c]
c = r(:,2);
r = r(:,1);
else # Assume it's [r;c]
c = r(2,:);
r = r(1,:);
end
elseif nargin!=3,
printf("ind2sub : 2 or 3 args are needed\n");
keyboard
end
ii=(c-1)*sz(1)+r;
if any(r<=0) || any(c<=0) || any(ii<=0),
if any(r<=0) , printf("ind2sub : Whoa!! negative rows\n"); end
if any(c<=0) , printf("ind2sub : Whoa!! negative columns\n"); end
if any(ii<=0), printf("ind2sub : Whoa!! negative subscript\n");end
keyboard
end
Produced by oct2html on Sat Dec 2 19:08:39 2000
Cross-Directory links are: ON