1
$\begingroup$

I am dealing with a fourth order polynomial. I get all of the desired out put however above a certain range I also get these - {}. From my understanding this means that there is no solution. I am trying to plot the final output however {} runes any chance of that. How could I remove the 'no solution'?

I have tried Select and Reduce.

Ddd = (a1) Dd^4 - (a2) Dd + (a2);
Table[NSolve[Ddd == 0, Dd, Reals], {t, t3}];

My output looks like this:

{{1.*10^-7, 0.000312683}, {1.0056*10^-7, 5.29149*10^-7}, {1.01653*10^-7, 3.59975*10^-7}, {1.0323*10^-7,  2.83353*10^-7}, {1.05406*10^-7, 2.36121*10^-7}, {1.08473*10^-7, 2.02102*10^-7}, {1.13219*10^-7, 1.74367*10^-7}, {1.23859*10^-7,   1.45755*10^-7}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}

I would just like to retain all the numbers an non of the rest.

Cheers for any ideas.

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Commented Nov 18, 2014 at 3:54

1 Answer 1

2
$\begingroup$

A couple of ways:

sols = {{1.*10^-7, 0.000312683}, {1.0056*10^-7, 
    5.29149*10^-7}, {1.01653*10^-7, 3.59975*10^-7}, {1.0323*10^-7, 
    2.83353*10^-7}, {1.05406*10^-7, 2.36121*10^-7}, {1.08473*10^-7, 
    2.02102*10^-7}, {1.13219*10^-7, 1.74367*10^-7}, {1.23859*10^-7, 
    1.45755*10^-7}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \
{}};


DeleteCases[sols, {}]
sols /. {} -> Sequence[]

Side remark:

If your code is

sols = Table[NSolve[Ddd == 0, Dd, Reals], {t, t3}];

then the output should have the form

((sol11, sol12,...), {sol21,...}, ..., {}, {}, ...}

If so, you can get rid of the {} with

Flatten[sols, 1]
$\endgroup$
2
  • $\begingroup$ Thank you very much Michael, that worked perfectly. I spent a really long time trying to find a way around it, I did not realize mathematica had this function...so much to learn. $\endgroup$
    – Valentin
    Commented Nov 18, 2014 at 15:22
  • $\begingroup$ @ValentinU You're welcome. $\endgroup$
    – Michael E2
    Commented Nov 18, 2014 at 17:43

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.