Replace certain columns of a matrix with 0?
Afficher commentaires plus anciens
Let's say I define a 10x10 matrix (call it "A") and want to re-define a new matrix (call it "A4") that is the same as matrix "A" except only the original first 4 columns are kept... and the last 6 columns are replaced with zeros?
Basically, how I get from this:
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
to something like this?
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
Fairly new to Mathcad here, so thanks any help anyone can give!
Réponses (1)
Walter Roberson
le 13 Oct 2015
A4 = A;
A4(:,5:end) = 0;
PS: we deal with MATLAB here, not with MathCad.
1 commentaire
Justin Bolinger
le 14 Oct 2015
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!