필터 지우기
필터 지우기

How to calculate the sum of particular row in a matrix??

조회 수: 6 (최근 30일)
Bibek Dhami
Bibek Dhami 2020년 7월 28일
댓글: Star Strider 2020년 7월 28일
I have a large matrix A with the dimension 1024 X 256. I want to add the elements of the 104th row from column 25 to 75. I tried this code but it doesn't work. Can someone please guide me on this?
B= sum(A(104, 25:75)

채택된 답변

Star Strider
Star Strider 2020년 7월 28일
To sum across a row, specify dimension 2:
B= sum(A(104, 25:75),2)
That should do what you want.
  댓글 수: 8
Bibek Dhami
Bibek Dhami 2020년 7월 28일
If I individually perform these operations, I can get the value. But I have 400 such files in the folder and I need these 400 values as you obtained for this particular file(206685). That's why I am trying to use for loop in the first case.
Star Strider
Star Strider 2020년 7월 28일
I understand.
The problem is that my ability to help you with the file problem is significantly limited. That is the reason that I encourage you to determine what is in ‘F’ before the loop and in each iteratiion, and what is in ‘file’ in each iteration. You simply need to list ‘F’ to determine what it is, and list every value of ‘F(i).name’, at least for the first few (perhaps 10) iterations, until the first loop works as you want it to work. One way to determine what is in ‘file’ is to use the size and nnz functions to see what is in it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by