필터 지우기
필터 지우기

Subtracting elements in an array

조회 수: 1 (최근 30일)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017년 1월 21일
댓글: Star Strider 2017년 1월 22일
hi there,
I have an array lets say
A=[10 9 10; 1 2 3; 4 5 6]
How can create an array like this?
B=[10-1 9-2 10-3;10-1-4 9-2-5 10-3-6]
thanks in advance!
Nikolas

채택된 답변

Star Strider
Star Strider 2017년 1월 21일
편집: Star Strider 2017년 1월 21일
If I understand correctly what you are asking, this will work:
A=[10 9 10; 1 2 3; 4 5 6]
B = cumsum(-A(2:end,:))+A(1,:)
A =
10 9 10
1 2 3
4 5 6
B =
9 7 7
5 2 1
  댓글 수: 9
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017년 1월 22일
ok got it, it works! thanks again mate..!!!
Star Strider
Star Strider 2017년 1월 22일
Our pleasure!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by