Skip to main content
2 of 2
Using lookup
Syed
  • 59.6k
  • 5
  • 40
  • 95
Clear["Global`*"]
tab1 = Flatten[
   Table[{i, j, 0}, {i, 0.5, 0.7, 0.1}, {j, 0.1, 0.3, 0.1}], {1, 2}];
tab2 = Flatten[
   Table[{i, j, i*j}, {i, 0.5, 0.7, 0.2}, {j, 0.1, 0.3, 0.2}], {1, 
    2}];

Create rules for a Lookup:

r1 = Sequence @@@ ({Most@# -> Last@#} & /@ tab2)

{{0.5, 0.1} -> 0.05, {0.5, 0.3} -> 0.15, {0.7, 0.1} -> 0.07, {0.7, 0.3} -> 0.21}

Sequence @@@ {Most@#, Lookup[r1, {Most@#}, Last@#]} & /@ tab1 

{{0.5, 0.1, 0.05}, {0.5, 0.2, 0}, {0.5, 0.3, 0.15}, {0.6, 0.1, 0}, {0.6, 0.2, 0}, {0.6, 0.3, 0}, {0.7, 0.1, 0.07}, {0.7, 0.2, 0}, {0.7, 0.3, 0.21}}

Syed
  • 59.6k
  • 5
  • 40
  • 95