changeset 761:307eee5730bf

montage: broadcast assignment (style fixes)
author carandraug
date Wed, 05 Jun 2013 14:57:37 +0000
parents 98903291ef63
children 00409c568443
files inst/montage.m
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/inst/montage.m
+++ b/inst/montage.m
@@ -252,10 +252,10 @@
     mRows = linspace (xRows(2,1:end-1) +1, xRows(1,2:end) -1, margin_width) (:);
     mCols = linspace (xCols(2,1:end-1) +1, xCols(1,2:end) -1, margin_width) (:);
 
-    disp_img(mRows,:,:)  = 0;
-    disp_img(mRows,:,:) += margin_color;
-    disp_img(:,mCols,:)  = 0;
-    disp_img(:,mCols,:) += margin_color;
+    ## a function that can be used to brodcast assignment
+    bd_ass = @(x, y) subsasgn (x, struct ("type", "()", "subs", {{":"}}), y);
+    disp_img(mRows,:,:) = bsxfun (bd_ass, disp_img(mRows,:,:), margin_color);
+    disp_img(:,mCols,:) = bsxfun (bd_ass, disp_img(:,mCols,:), margin_color);
   endif
 
   ## 4) display the image