MATLAB: I want to access every nth value of a large matrix. How to do that matrix I require a matlab code for resultant matrix obtained by picking every 9th element of a very large matrix. How can I do that? Best Answer Where M is your matrix, using simple subscript indexing:M(1:9:end,1:9:end)Or using linear indexing (not likely that you want this, but worth mentioning):M(1:9:end) Related SolutionsMATLAB: Writing a Nth order matrix. Just keep it simple:>> a = 1:5;>> M = diag(ones(1,numel(a)-1),1);>> M(end,:) = aM = 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 2 3 4 5 MATLAB: Access every nth occurrence of a value in a matrix One approach: Atv = reshape(A', [], 1); % Transpose & Reshape To Column Vectorlidx = find(Atv); % Find ‘1’ PositionsB = zeros(size(A))'; % Create Transpose Of ‘B’B(lidx(1:3:end)) = 1; % Set Appropriate Elements To ‘1’B = B' % Transpose To Get Desired Result Related QuestionMatrixHow to delete every nth rowFinding average of every nth row
Best Answer