MATLAB: How to index a cell vector of strings cell index I have a vector of cells, each one is 'x' or 'y'. How can I index them, similar to the "find" function? Thank you. Best Answer s={'a','b','x','c','d','x'}idx=find(ismember(s,'x')) Related SolutionsMATLAB: How to repeat a cell Does it just occur once?x = {'b','c','d','e','f','a','y','z','h','i','j'};x = x(:);y = cell(length(x)+1,1);idxarray = strcmp(x,'a');idx = find(idxarray == 1);y{idx+1} = 'a';y(1:idx) = x(1:idx);y(idx+2:end) = x(idx+1:end); MATLAB: How to use ismember to assign values from one cell array to another cell array Assuming that each cell contains exactly one character:>> [idx,idy] = ismember(cell2mat(y(:,2:3)),cell2mat(x(:,2:3)),'rows');Or, as most likely each cell contains multiple characters in a vector, you can do this:>> [idx,idy] = ismember(strcat(y(:,2),'*',y(:,3)),strcat(x(:,2),'*',x(:,3)));And then simply:>> y(idx,4) = x(idy(idx),1)y = [2] 'A' 'B' 'C' [2] 'A' 'D' 'B' Related Question2-D Bilinear interpolationPloting 3d constrainsCounting equal numbers that appear directly next to each otherGetting rid of empty cells in a cell arrayUsing the max function to recieve two outputsFinding elements of one vector that are closest to elements of another
Best Answer