Difference between columns, fixed the first column, in a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Montserrat Vallcorba Martí
am 3 Nov. 2017
Kommentiert: Montserrat Vallcorba Martí
am 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169120/image.jpeg)
Thank you in advance!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 3 Nov. 2017
Bearbeitet: Andrei Bobrov
am 3 Nov. 2017
B = bsxfun(@minus,A(:,2:end,:),A(:,1,:));
B(B<0) = 0;
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!