MATLAB: How to add new data to specific row and colum of a matrix matrix Eg: A = [1 2 5; 3 4 6; 7 8 9]; i want to make it A = [1 0 2 5; 3 0 4 6; 0 0 0 0; 7 0 8 9]; Thank you Best Answer EDITB= [1 2 5; 3 4 6; 7 8 9]n1=2 %Position of the row to addm1=3 %position of the column to add%-------------------------A=zeros(size(B)+2)A(2:end-1,2:end-1)=B[n,m]=size(A)A=[A(:,1:m1) zeros(n,1) A(:,m1+1:end)]A=[A(1:n1,:); zeros(1,m+1) ;A(n1+1:end,:)]A([1 end],:)=[];A(:,[1 end])=[] Related SolutionsMATLAB: How to add zeros column and row at the beginning of matrix new_A=zeros(size(B));new_A(2:end,2:end)=A; MATLAB: Comparing two matrix for similar matrix a = [1 2 3];b = [1 2 3; 4 5 6; 7 8 9];i = ismember(b , a, 'rows');c = b(~i,:) Related QuestionHow to change part of a matrix into zeroHow to add zeros above the numbers I created with this codeHelp running Matlab scriptHow to modify a matrix to change the entries >=0 and multiply it by 5 AND to change the entries <0 and add 2 to those entriesAppend rows at the end of Matrix
Best Answer