MATLAB: Adding element to a matrix row MATLAB hi, i want to add to a matrix edhe next element to the next column e.g calculate an element add to position matrix(1,1) calculate next element add to position matrix(1,2) … jump to next row and do the same … Best Answer You can read this to know about matrix indexing:https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.htmlYou can do something like:m = nbRow;n = nbCol;M = zeros(m,n);for i = 1 : nbRow for j = 1 : nbCol a = i + j ;% some calculation M(i,j) = a; endend Related SolutionsMATLAB: Occrency text array number One way of doing it:tableau_string = {'3.5' 'alain' '3.5' 'alain'; 'alain' '' 'alain' 'test'; '' 'test' '' 'test'; '5' 'test' '5' 'test'};[strings, ~, position] = unique(tableau_string(:));count = accumarray(position, ones(1, numel(tableau_string)));stringcounts = [strings num2cell(count)] %if you want it all in a cell arrayYou could use histc or hiscounts instead of accumarray for the same result. MATLAB: How do you create a matrix Aij where each value is determined by a formula [I,J] = ndgrid(1:2,1:2);(-1).^(I+J) Related QuestionSum of range of matrix elements from starting and end pointHow to repeat subjects label by simplify wayHow can i sort columns of a matrix in ascending order using loops without using the functions max,min,sort
Best Answer