Subtract column from previous column in for loop
Show older comments
I want to subtract previous column from columns, eg. column 2 - column 1 etc., and then divide by the difference (range) between the column values, per row of a large matrix.
For example I have matrix
A = [1 2 3; 4 5 6; 7 8 9]
I want to get matrix:
B = [0 1 1;0 1 1; 0 1 1]
and then divide by the range, which in this case is 0 but for me it won't be, and will be different for each row
I think I can use bsxfun, but am unsure how to use this in a loop, and using values from previous iteration in loop. I am very new to Matlab, and any help will be greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!