MATLAB: How is this simple code read MATLABsimple My code is as follows : mat = [1 2 3 ; 4,5,6 ; 7 8 9];mat([2 3], [2 3]) Question: Why is the output 5 68 9 and how is that determined? Best Answer It is the 2nd & 3rd rows and the 2nd & 3rd columns of the matrix mat. The syntax is simply extracting a sub-matrix of the original. Related SolutionsMATLAB: Is it possible to extract the values with a vector of indices for each row without using the for statement from the matrix see sub2ind()A = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; % reference matrixb = [2; 1; 1; 3]; % index for each row that I want to extractidx = sub2ind(size(A), 1:size(A,1), b.');A(idx)Result>> A(idx)ans = 2 4 7 12 MATLAB: Simple question usingChangesN = find(diff(S))would demonstrate where the value was changing and then to see how many time this happens:length(ChangesN) Related QuestionHow to find a subset matrix in the main matrix and build a new matrixSimple IntegrationSimple operationsSimple calculations
Best Answer