# Create a matrix with a given sparsity pattern and whose condition number is low

In Matlab, I need to create a symmetric matrix with a given sparsity pattern and whose condition number is low ($\leq 10$). The matrix is sparse (more than half of its entries are zero).

From what I already know, generally if diagonal entries are larger and if the value of the entries are taken from a function, the condition number will be low.

### Update

As an example of structure, we can consider Jacobian matrices or matrices whose graph is a star.

• The identity matrix fullfills your conditions. You need to be more precise. – nicomezi Aug 14 '18 at 6:35
• @nicomezi it has not the specified structure. – M a m a D Aug 14 '18 at 6:36
• Well, more then half of the entries are zero, diagonal entries are larger then nondiagonal and those are taken by the null function. That is why I am asking you to be more precise. – nicomezi Aug 14 '18 at 6:38
• @nicomezi I updated the question – M a m a D Aug 14 '18 at 6:40
• @RodrigodeAzevedo the value of non-zero entries are random (random for top triangle, the same will be used for bottom triangle) – M a m a D Aug 15 '18 at 10:08

Is there a reason you are not using sprandsym(n,density,rc) with density$\geq 0.5$ and rc$\in (0.1,\infty)$ (documentation)?

• I don't know what that is!!! – M a m a D Aug 15 '18 at 10:07