필터 지우기
필터 지우기

how to change part of a matrix into zero

조회 수: 15 (최근 30일)
napo
napo 2013년 12월 7일
댓글: djibeyrou ba 2020년 5월 21일
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]

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 7일
n1=ceil(0.1*size(A,1));
A(1:n1,:)=0

추가 답변 (2개)

Andrei Bobrov
Andrei Bobrov 2013년 12월 7일
n = round(numel(A)*.1);
B = A';
B(1:n) = 0;
B = B';
  댓글 수: 2
napo
napo 2013년 12월 7일
very nice work, thank you
djibeyrou ba
djibeyrou ba 2020년 5월 21일
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

댓글을 달려면 로그인하십시오.


djibeyrou ba
djibeyrou ba 2020년 5월 21일
I need help with this code

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by