MATLAB: How to remove a word from an array

#removewords #array

This is what I have:
xA=[0 4 2 1]; wA=struct('name',{'person1' 'person2' 'person3' 'person4'},'num',num2cell(xA)); peopleA={wA.name}; numA=[wA.num]; [idxA,idxA]=max(numA); primeroA=peopleA{idxA} numAA=numA(numA~=max(numA)); [idxxA,idxxA]=max(numAA); segundoA=peopleA{idxxA}
I want to remove the maximum of the word, that is, the word contained in primeroA, in order to be able to calculate the second maximum without the words being rearrenged or altered.

Best Answer

xA=[0 4 2 1];
name={'person1' 'person2' 'person3' 'person4'};
[a,b] = unique(xA);
out = name(b(end-1));