Borrar filtros
Borrar filtros

how to change part of a matrix into zero

15 visualizaciones (últimos 30 días)
napo
napo el 7 de Dic. de 2013
Comentada: djibeyrou ba el 21 de Mayo de 2020
i have a matrix A= (m,n) and i want to make the first 10% row elements 0 suppose A= [1 1 1; 2 2 2; 3 3 5; 4 4 4; 5 5 1; 6 1 3; 1 6 5; 7 7 1; 4 8 2; 5 0 9] will become B= [0 0 0; 2 2 2; 3 3 5; 4 4 4; 5 5 1; 6 1 3; 1 6 5; 7 7 1; 4 8 2; 5 0 9]

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 7 de Dic. de 2013
n1=ceil(0.1*size(A,1));
A(1:n1,:)=0

Más respuestas (2)

Andrei Bobrov
Andrei Bobrov el 7 de Dic. de 2013
n = round(numel(A)*.1);
B = A';
B(1:n) = 0;
B = B';
  2 comentarios
napo
napo el 7 de Dic. de 2013
very nice work, thank you
djibeyrou ba
djibeyrou ba el 21 de Mayo de 2020
a=4;
b=3;
A=zeros(a,b);
B=size(A)
if a== b
B=A==-1;
else
B=A==0;
end
disp(B)
I need help with this code i want to change some value in the matrix

Iniciar sesión para comentar.


djibeyrou ba
djibeyrou ba el 21 de Mayo de 2020
I need help with this code

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by