Subtract column from previous column in for loop
이전 댓글 표시
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!