Adding zeros to a matrix to match the dimensions of two matrices.
Mostra commenti meno recenti
Hi ! need help to match the size of two matrices. I have two matrices of dimensions mxn and jxk. I want make mxn of size jxk by adding zeros at the end of the mxn. A of mxn dimenssion and B of jxk dimenssion. Am doing by this way:
newA=[A,zeros(size(B)]
1 Commento
ammara khurshid
il 27 Nov 2017
Modificato: ammara khurshid
il 27 Nov 2017
Risposta accettata
Più risposte (1)
James Tursa
il 27 Nov 2017
Another way:
newA = zeros(size(B));
newA(1:size(A,1),1:size(A,2)) = A;
2 Commenti
Guillaume
il 27 Nov 2017
Yes, actually simpler than my answer. And in case A is not of class double:
newA = zeros(size(B), 'like', A);
ammara khurshid
il 2 Dic 2017
Categorie
Scopri di più su Sparse Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!