index.m

来自「《Digital and Analog Communications Syste」· M 代码 · 共 33 行

M
33
字号
function pos = index(x,value)
% File: INDEX.M
% CALL: pos = index(x,value)
% This function returns the index of the x vector that equals value.
% That is, x(pos) = value

i = 1;
j = -1;
x = x(:);
temp = 0;
while (temp == 0)
  if (x(i) == value)
    j = 1;
    temp = 1;
  else
    i = i+1;
    if (i > length(x))
      temp = 1;
    end;
  end;
end;

if (j ~= -1)
  pos = i;
else
  pos = -1;
end;
end;




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?