필터 지우기
필터 지우기

how to compute number of element in matrix ?

조회 수: 3 (최근 30일)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016년 4월 28일
답변: Azzi Abdelmalek 2016년 4월 28일
if i have this matrix
A = [ 1 3 2 0
2 2 1 0
1 2 1 1 ]
first i want to compute x which mean the sum of element in each row like this
x = [ 6
5
5 ]
second i want to compute y which mean the number of element non zero in each row like this
y = [ 3
3
4 ]

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 28일
A = [ 1 3 2 0
2 2 1 0
1 2 1 1 ]
a=sum(A,2)
b=sum(A~=0,2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by