0
$\begingroup$

I have a list of solutions from a LinearSolve :

Table[LinearSolve[mat, vect], {x0, 0.1, 0.3, 0.1}, {x1, 0.4, 0.7, 
  0.1}, {w0, 0.4, 0.7, 0.1}, {w1, 0.1, 0.3, 0.1}]

Sometimes Mathematica manages to find a solution, sometimes not.

How could I select only the results and not all the failures in :

{{{0.45, 0.1, 0.1, 
   0.45, {{0.030407}, {1.12655}, {0.030407}, {-1.86933}, {-1.}, \
{0.}}}, {0.45, 0.1, 0.2, 0.45, 
   LinearSolve[{{0.449, 0.248506, 0.099, 0.044999, 0.009999, 
      0}, {-6.10925, -0.796506, 0, -0.099, 0, 
      0}, {0, -0.796506, -4.60517, -0.449, -0.198, 0}, {0.199, 
      0.39982, 0.449, 0.089999, 0.202499, 0}, {-5.29832, -1.04782, 
      0, -0.449, 0, 0}, {0, -1.04782, -6.10925, -0.199, -0.898, 
      0}}, {{0.202499}, {-0.898}, {0}, {0.039999}, {-0.398}, {0}}]}, \
{0.45, 0.1, 0.3, 0.45, 
   LinearSolve[{{0.449, 0.248506, 0.099, 0.044999, 0.009999, 
      0}, {-6.10925, -0.796506, 0, -0.099, 0, 
      0}, {0, -0.796506, -4.60517, -0.449, -0.198, 0}, {0.299, 
      0.636292, 0.449, 0.134999, 0.202499, 0}, {-5.70378, -1.38429, 
      0, -0.449, 0, 0}, {0, -1.38429, -6.10925, -0.299, -0.898, 
      0}}, {{0.202499}, {-0.898}, {0}, {0.089999}, {-0.598}, {0}}]}}, \
{{0.55, 0.1, 0.1, 0.45, 
   LinearSolve[{{0.549, 0.39982, 0.099, 0.054999, 0.009999, 
      0}, {-6.30992, -1.04782, 0, -0.099, 0, 
      0}, {0, -1.04782, -4.60517, -0.549, -0.198, 0}, {0.099, 
      0.248506, 0.449, 0.044999, 0.202499, 0}, {-4.60517, -0.796506, 
      0, -0.449, 0, 0}, {0, -0.796506, -6.10925, -0.099, -0.898, 
      0}}, {{0.302499}, {-1.098}, {0}, {0.009999}, {-0.198}, {0}}]}, \
{0.55, 0.1, 0.2, 0.45, 
   LinearSolve[{{0.549, 0.39982, 0.099, 0.054999, 0.009999, 
      0}, {-6.30992, -1.04782, 0, -0.099, 0, 
      0}, {0, -1.04782, -4.60517, -0.549, -0.198, 0}, {0.199, 0.39982,
       0.449, 0.089999, 0.202499, 0}, {-5.29832, -1.04782, 0, -0.449, 
      0, 0}, {0, -1.04782, -6.10925, -0.199, -0.898, 
      0}}, {{0.302499}, {-1.098}, {0}, {0.039999}, {-0.398}, {0}}]}, \
{0.55, 0.1, 0.3, 0.45, 
   LinearSolve[{{0.549, 0.39982, 0.099, 0.054999, 0.009999, 
      0}, {-6.30992, -1.04782, 0, -0.099, 0, 
      0}, {0, -1.04782, -4.60517, -0.549, -0.198, 0}, {0.299, 
      0.636292, 0.449, 0.134999, 0.202499, 0}, {-5.70378, -1.38429, 
      0, -0.449, 0, 0}, {0, -1.38429, -6.10925, -0.299, -0.898, 
      0}}, {{0.302499}, {-1.098}, {0}, {0.089999}, {-0.598}, {0}}]}}, \
{{0.65, 0.1, 0.1, 0.45, 
   LinearSolve[{{0.649, 0.636292, 0.099, 0.064999, 0.009999, 
      0}, {-6.47697, -1.38429, 0, -0.099, 0, 
      0}, {0, -1.38429, -4.60517, -0.649, -0.198, 0}, {0.099, 
      0.248506, 0.449, 0.044999, 0.202499, 0}, {-4.60517, -0.796506, 
      0, -0.449, 0, 0}, {0, -0.796506, -6.10925, -0.099, -0.898, 
      0}}, {{0.422499}, {-1.298}, {0}, {0.009999}, {-0.198}, {0}}]}, \
{0.65, 0.1, 0.2, 0.45, 
   LinearSolve[{{0.649, 0.636292, 0.099, 0.064999, 0.009999, 
      0}, {-6.47697, -1.38429, 0, -0.099, 0, 
      0}, {0, -1.38429, -4.60517, -0.649, -0.198, 0}, {0.199, 0.39982,
       0.449, 0.089999, 0.202499, 0}, {-5.29832, -1.04782, 0, -0.449, 
      0, 0}, {0, -1.04782, -6.10925, -0.199, -0.898, 
      0}}, {{0.422499}, {-1.298}, {0}, {0.039999}, {-0.398}, {0}}]}, \
{0.65, 0.1, 0.3, 0.45, 
   LinearSolve[{{0.649, 0.636292, 0.099, 0.064999, 0.009999, 
      0}, {-6.47697, -1.38429, 0, -0.099, 0, 
      0}, {0, -1.38429, -4.60517, -0.649, -0.198, 0}, {0.299, 
      0.636292, 0.449, 0.134999, 0.202499, 0}, {-5.70378, -1.38429, 
      0, -0.449, 0, 0}, {0, -1.38429, -6.10925, -0.299, -0.898, 
      0}}, {{0.422499}, {-1.298}, {0}, {0.089999}, {-0.598}, {0}}]}}}

Thank you in advance

$\endgroup$
1
  • $\begingroup$ What exactly is the output you need in what you posted? And would it be possible to provide a toy example? $\endgroup$
    – Titus
    Apr 27, 2020 at 17:11

1 Answer 1

2
$\begingroup$

Is this what you're looking for?

DeleteCases[output, _?(Head[#] == LinearSolve &), -1]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.