Hot answers tagged

6

First answer (extended comment actually) You have to define better your objective function. For example, the following works: ClearAll[mat, minev] SeedRandom[1] rm = RandomInteger[10, {40, 40, 3}]; mat[t_] := N[rm.{1, t, t^2}]; minev[t_?NumericQ] := First@Eigenvalues[mat[t], -1]; Take[Table[minev[t], {t, 0, 1, .01}], 3] (* {-0.864071 - 1.30548 I, ...


2

This looks convoluted, but it matches the requirements you set up Fold[ Function[{matrix, index}, ReplacePart[matrix, index -> RandomChoice[ Select[ lookupMatrix, (Last@# == startingMatrix[[First@index, -1]] &)][[All, Last@index]] ]]], startingMatrix, Position[startingMatrix, "Null"]] (* {{1, 2, 3, 4, 5, 5.5, 6, 7, ...


1

This isn't much different than JasonB's answer in substance, but it's easier to debug and it's usually how I first approach problems with lots of steps: Module[ {nullPos, nullGroup, nullReplacements}, nullPos = Position[startingMatrix, "Null"]; nullGroup = Last@startingMatrix[[First@#]] & /@ nullPos; nullReplacements = Cases[lookupMatrix, {___, x_} ...



Only top voted, non community-wiki answers of a minimum length are eligible