matlab应该怎么在循环中追加元胞数组?

matlab追加元胞数组时,元胞数组的值总是会被覆盖,应该怎么追加元胞数组?

function results = FindPhoneNumber0(searchstring, contacts)
load(contacts);

% Scan through contacts
peopleFound = 1;
results{peopleFound}={};
for i=1:length(names)
    myMessage = {names{i},phonenumbers{1}};
    str = names(i);
    len = length(str);
    currentName = myMessage{1};
    if length(strfind(currentName, searchstring)) > 0     
        % if we find a name match, add name and number to results        
        results{peopleFound} = {myMessage{1}, myMessage{2}};
        peopleFound = peopleFound + 1;
    else
        peopleFound = 1;
    end
end

我得到的结果:

img

img

img

直觉觉得是因为i的值一直停留在1

应该得到的结果

img