<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">and other idea is :<div><br></div><div>diag( a ( : , c ( : ) ) ) </div><div><br></div><div>fred</div><div><br><div><div>Le 25 janv. 2011 à 15:32, Jean-Damien Capdeville a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Dear all,<br><br>I'm looking to extract from a matrix "A" one value for each line. The column<br>positions of the value to extract would be given by a vector "c".<br><br>Here is an example:<br>A = [ 1 2 3 ; 4 5 6 ; 7 8 9 ; 10 11 12 ; 13 14 15 ]<br><br>c = [ 3 ; 1 ; 1 ; 2 ; 3 ]<br><br>How can I get the resulting vector [ 3 ; 4 ; 7 ; 11; 15 ] ?<br><br>I'm currently using a loop which is obviously a time expensive solution with<br>large matrix.<br>Any ideas to get it more efficiently?<br><br>Thanks,<br><br><br>Jean-Damien<br><br><br><br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-size: 12px; "><div><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" face="Times"><br></font></span></div></span></div></div></span></span></div></div></body></html>