Changing the boundary rows and columns.
Afficher commentaires plus anciens
I'm having a bit of a problem finding a solution to this most likely due to the answer being relatively simple. I have a matrix of all ones. Let's say,
[1,1,1,1; 1,1,1,1; 1,1,1,1] What I need to do is relatively simple. I need to change the values of the first and last columns and rows to zero such that the matrix would be.
[0,0,0,0; 0,1,1,0; 0,0,0,0]
Is there a way to tell matlab to give a value of zero to every number within a given column or row?
Réponse acceptée
Plus de réponses (1)
Paulo Silva
le 27 Avr 2011
m=[1,1,1,1; 1,1,1,1; 1,1,1,1];
m(:,1)=0; %all lines, first column
m(1,:)=0; %all columns, first line
m(:,size(m,2))=0; %all lines, last column
m(size(m,1),:)=0; %all columns, last line
Catégories
En savoir plus sur Mathematics 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!