Difference between columns, fixed the first column, in a matrix
1 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169120/image.jpeg)
Thank you in advance!
0 个评论
采纳的回答
更多回答(1 个)
Andrei Bobrov
2017-11-3
编辑:Andrei Bobrov
2017-11-3
B = bsxfun(@minus,A(:,2:end,:),A(:,1,:));
B(B<0) = 0;
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!