Note that there are some explanatory texts on larger screens.

plurals
  1. POFormat matrix into txt file with appropriate blank lines
    primarykey
    data
    text
    <p>I am working with a triangulation program and I need to plot the data points and their triangulation (obtained from another program). So I have my delauany edges matrix <strong>newgrid1_eDT</strong> (e for edge list) as (first column is line number):</p> <pre><code>1 0 0 9 2 0 1 9 3 0 1 9 4 0 1 8 5 0 1 8 [...] 11716 5 6 8 11717 1 2 4 11718 0 2 4 </code></pre> <p>and the idea is to make it like this newgrid1_ASCIIeDT:</p> <pre><code>1 0 0 9 2 0 1 9 3 4 0 1 9 5 0 1 8 6 7 0 1 8 [...] 11715 5 6 8 11716 11717 1 2 4 11718 0 2 4 </code></pre> <p>Basically, each 2 rows represent a 3d coordinate pair (and each pair of points represents a line).</p> <p>I have written the following in an attempt to copy two rows (index i) consecutively from <strong>newgrid1_<em>eDT</strong> followed by a blank line to <strong>newgrid1</em>_ASCIIeDT</strong> (index j), thus looping through the empy matrix <strong>newgrid1_<em>ASCIIeDT</strong> filling it gradually. I have allocated 11718+ 11718/3 =15624 rows in the recieving matrix <strong>newgrid1</em>_ASCIIeDT</strong>; one for each point we tranfer over from <strong>newgrid1__eDT</strong> plus one empty mrow after every 2 lines (at rows 3,6,9,... and so on):</p> <pre><code>newgrid1__ASCIIeDT=zeros(15624,3); [m,l]=size(newgrid1__ASCIIeDT) ; j=0; i=1; for j = 1:3:15624 i newgrid1__ASCIIeDT(j,:)=newgrid1__eDT(i,:); newgrid1__ASCIIeDT(j+1,:)=newgrid1__eDT(i+1,:); newgrid1__ASCIIeDT(j+2,:)=blank; i=i+1 end </code></pre> <p>For some reason I am convinced this should do the trick but somehow I get weird results. Are there any other (simpler ways) of doing this or am I reinventing the wheel?</p> <p>Ideally I would have written this in C (where all the other stuff is happening) but I just need a quick fix at the moment and cant go through 11k lines to introduce blank lines. Any help please ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload