MATLAB: Search indecies in matrix arraymatrix thank you very much Best Answer l1 = {'A' 'B'; 'B' 'A'; 'B' 'C'; 'C' 'D'; 'D' 'E'; 'E' 'F'; 'F' 'E'; 'F' 'C'; 'C' 'F'; 'F' 'B'; 'B' 'F'; 'F' 'G'; 'G' 'F'; 'G' 'A'; 'G' 'E'; 'E' 'G'};x = {'B' 'C' 'D' 'E' 'F' 'G'};numberRows = size(l1,1);numberCols = size(x,2) + 1; % Offsetting by one, to compensate for the 0 values in loc. Will chop that off later.[~,loc] = ismember(l1,x);loc1 = loc(:,1)+1;loc2 = loc(:,2)+1;A = zeros(numberRows,numberCols);linearIndex1 = sub2ind(size(A),1:numberRows,loc1');linearIndex2 = sub2ind(size(A),1:numberRows,loc2');A(linearIndex1) = -1;A(linearIndex2) = 1;% Chop off spurious first columnA(:,1) = []; Related SolutionsMATLAB: How to improve a for -sum(Q.*Q) MATLAB: How to add columns to cell array [cells repmat({'-'},3,2)] Related QuestionAdd values to one valueHow to access the cell arrayI need final equation…Create a cell array of mixed dimensionVectorisation of a simple for loopQuestion about strings on a matrix.Find multiple words in a cellCell array value based on poisiton
Best Answer