Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
% function [w,N] = where(invec,num)
% finds where num is located in 1D vector invec
% returns all N instances
% See also where2.m for 2D matrix
function [w,N] = where(invec,num)
eps = 1e-3;
[sy,sx] = size(invec);
if sx == 1
invec = invec';
end
[dum,sz] = size(invec);
w = -1;
ind = 0;
for loop = 1:sz
tst = abs(invec(loop)-num);
if tst < eps
ind = ind+1;
w(ind) = loop;
end
end
N = ind;
[dum,Ntemp] = size(w);
if (Ntemp ==1&w==-1)
N = 0;
end