Prev: china
Next: automatic gain control
From: Martin on 26 Jun 2010 08:17 I have a 2 column text file consisting of a pixel number and its corresponding output. For instance, a simplified version could look like this: 9 5 23 4 66 7 75 2 9,23,66,75 are pixel numbers and 5,4,7,2 are their outputs. The detector is a grid of 10 times 10 pixels. I need to generate a 10 times 10 matrix that puts zeros where there is no recorded output and places the few measured outputs in their proper matrix positions. In another words, I need to convert this text 2 column file into a square matrix with zeros where no measured data appeared. Please, could you help? Thank You!
From: us on 26 Jun 2010 08:24 "Martin " <nikolom(a)gmail.com> wrote in message <i04r40$6th$1(a)fred.mathworks.com>... > I have a 2 column text file consisting of a pixel number and its corresponding output. For instance, a simplified version could look like this: > > 9 5 > 23 4 > 66 7 > 75 2 > > 9,23,66,75 are pixel numbers and 5,4,7,2 are their outputs. The detector is a grid of 10 times 10 pixels. I need to generate a 10 times 10 matrix that puts zeros where there is no recorded output and places the few measured outputs in their proper matrix positions. > > In another words, I need to convert this text 2 column file into a square matrix with zeros where no measured data appeared. > > Please, could you help? > Thank You! one of the many solutions pel=[ 9,5 23,4 55,2 ]; img=zeros(10); img(pel(:,1))=pel(:,2); imagesc(img); axis image; us
From: Martin on 26 Jun 2010 09:14 "us " <us(a)neurol.unizh.ch> wrote in message <i04rh5$31o$1(a)fred.mathworks.com>... > "Martin " <nikolom(a)gmail.com> wrote in message <i04r40$6th$1(a)fred.mathworks.com>... > > I have a 2 column text file consisting of a pixel number and its corresponding output. For instance, a simplified version could look like this: > > > > 9 5 > > 23 4 > > 66 7 > > 75 2 > > > > 9,23,66,75 are pixel numbers and 5,4,7,2 are their outputs. The detector is a grid of 10 times 10 pixels. I need to generate a 10 times 10 matrix that puts zeros where there is no recorded output and places the few measured outputs in their proper matrix positions. > > > > In another words, I need to convert this text 2 column file into a square matrix with zeros where no measured data appeared. > > > > Please, could you help? > > Thank You! > > one of the many solutions > > pel=[ > 9,5 > 23,4 > 55,2 > ]; > img=zeros(10); > img(pel(:,1))=pel(:,2); > imagesc(img); > axis image; > > us It did not work. B=[ 9 5 23 4 66 7 75 2 ]; A=zeros(10); A(B(:,1)=B(:,2); ??? A(B(:,1)=B(:,2); | Error: The expression to the left of the equals sign is not a valid target for an assignment.
From: us on 26 Jun 2010 09:25 "Martin " > It did not work. > > B=[ > 9 5 > 23 4 > 66 7 > 75 2 > ]; > A=zeros(10); > A(B(:,1)=B(:,2); > ??? A(B(:,1)=B(:,2); > | > Error: The expression to the left of the equals sign is not a valid target for an assignment. > well... of course... you made a typo A(B(:,1) % must read A(B(:,1)) % as shown in the original solution... us
From: Martin on 26 Jun 2010 10:43
"us " <us(a)neurol.unizh.ch> wrote in message <i04v41$l8e$1(a)fred.mathworks.com>... > "Martin " > > It did not work. > > > > B=[ > > 9 5 > > 23 4 > > 66 7 > > 75 2 > > ]; > > A=zeros(10); > > A(B(:,1)=B(:,2); > > ??? A(B(:,1)=B(:,2); > > | > > Error: The expression to the left of the equals sign is not a valid target for an assignment. > > > > well... of course... > you made a typo > > A(B(:,1) > % must read > A(B(:,1)) > % as shown in the original solution... > > us Thank You! My mistake. I was hoping for A(9)=5 to be in the first row, ninth column. Now it is in the first column ninth row. I hoped to get a matrix looking like 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 2 0 0 0 0 0 and so forth. It seems setting C=A' to transpose it fixes it. Thank You again! |