MATLAB Answers

Bob Choy

Subtract values in a matrix

Asked by Bob Choy
on 17 Nov 2012

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.



No products are associated with this question.

1 Answer

Answer by Matt J
on 17 Nov 2012



Thank you it worked!!! But can I do this using for's?

Matt J
on 17 Nov 2012

Sure, but why?

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

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!