Thanks, these steps put me closer, however LNOx_vert_land(mask) is a 25180 x 1 array. I want to replace those 25180 elements from LNOx_vert_land to LNOx_vert_ocean.
"Steven_Lord" <email@example.com> wrote in message <firstname.lastname@example.org>... > > > "Jonathan W Smith" <email@example.com> wrote in message > news:firstname.lastname@example.org... > > I have 2 arrays: > > > > LNOx_vert_ocean = bsxfun(@times, apply_250_km2, lnox_mass_frac_ocean); > > LNOx_vert_land = bsxfun(@times,apply_250_km2, lnox_mass_frac_land); > > Both will have the size 332 x 165 x 27 x 3. > > > > I want to substitute SOME (not all) elements in LNOx_vert_ocean with some > > elements in LNOx_vert_land. > > > > The substitution will be based off of a 3rd array LU (land use). This > > array is 332 x 165. If the value of the elements in LU is not equal 16 > > then that is land. Those are the values to be substituted into > > LNOx_vert_ocean. > > > > Amongst several things I have tried the following which did not work: > > LNOx_vert = LNOx_vert_ocean(LNOx_vert_land(LU ~= 16)); > > No, that won't. Work your way outward to describe what that line is doing. > > 1) (LU ~= 16) creates a logical array with 1 where the corresponding element > of LU is not equal to 16 and 0 where it is. > 2) LNOx_vert_land(step 1) returns those elements of LNOx_vert_land where the > corresponding elements of LU are not equal to 16. > 3) LNOx_vert_ocean(step 2) returns those elements of LNOx_vert_ocean where > the corresponding elements of LNOx_vert_land correspdong to elements of LU > that are not equal to 16. That's not what you're looking for, is it? > > > Instead, use step 1 as a mask into each of LNOx_vert_ocean and > LNOx_vert_land separately. > > mask = (LU ~= 16); > LNOx_vert_ocean(mask) = LNOx_vert_land(mask); > > That replaces those elements in LNOx_vert_ocean that correspond to non-16 > elements in LU with the elements in LNOx_vert_land that correspond to non-16 > elements in LU -- or to put it another way, it replaces those elements in > LNOx_vert_ocean that correspond to land with the elements of LNOx_vert_land > that correspond to land. Does that description match what you want to do? > > -- > Steve Lord > email@example.com > To contact Technical Support use the Contact Us link on > http://www.mathworks.com