Subtract values in a matrix

Hi there!
I need really need some help on this, I have a matrix which has "l" lines and "c" columns. I want to subtract each value in the matrix by the value the first value in the first line of its column, and give me a matrix with those values, with the first values of the first line being "0", and the same amount of lines and columns
Example: m = [2,2,2;3,3,3;4,4,4] the matrix given should be [0,0,0;-1,-1,-1;-2,-2,-2]
I hope I made myself understood, if not, please ask away.
Thank you for your time.

답변 (1개)

Matt J
Matt J 2012년 11월 17일

0 개 추천

bsxfun(@minus,m(1,:),m);

댓글 수: 3

Bob Choy
Bob Choy 2012년 11월 17일
편집: Bob Choy 2012년 11월 17일
Thank you it worked!!! But can I do this using for's?
Matt J
Matt J 2012년 11월 17일
Sure, but why?
Bob Choy
Bob Choy 2012년 11월 17일
Because we are using them in the project Im developing and I wanna be coherent but if thats too much trouble for you feel free not to bother, your have helped enough

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

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2012년 11월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by