Right now I'm playing around with matrices and PDL. I have some code that will do SVD on a matrix ($a, $b, $c) = svd($matrix), the results for $b looking like this
[0.97069051 0.57504129 0.09337227 0.012809204]
What I am now trying to do is to extract the three values from matrix b and assign them as three different variables. My first thought was to copy the contents of the matrix into an array and then use substr. This works up to a point but the finished program will be dealing with a number of matrices for which svd will have to be performed, so a general substr approach wont work (as the number of decimal places will vary with each calculation). I'm guessing that I might be able to extract the data using regular expressions instead? Any suggestions much appreciated

In reply to Extracting info from matrix by Angharad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.