Difference between columns, fixed the first column, in a matrix
2 views (last 30 days)
Show older comments
Montserrat Vallcorba Martí
on 3 Nov 2017
Commented: Montserrat Vallcorba Martí
on 3 Nov 2017
Hi, I have a 3D-matrix and I want to calculate differences between columns, fixed the first column, and the value be positive or zero, i.e., for each 3D dimension calculate: max ( column(i)-column(1), 0 ). For example:
Thank you in advance!
0 Comments
Accepted Answer
More Answers (1)
Andrei Bobrov
on 3 Nov 2017
Edited: Andrei Bobrov
on 3 Nov 2017
B = bsxfun(@minus,A(:,2:end,:),A(:,1,:));
B(B<0) = 0;
See Also
Categories
Find more on Elementary Math 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!