MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayNew to MATLAB?
MATLAB Central > MATLAB Newsreader > Problem using horzcat with index vectors in a for ... 

Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 20 Jan, 2013 23:22:07 Message: 1 of 13 
Hi 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 21 Jan, 2013 11:02:09 Message: 2 of 13 
Note that the code works through the list and concatenates the correct matching rows. However, D is overwritten with each iteration. I would like each concatenated row to be added to a new m x 4 matrix where the number of rowsand order of matched columns is equal to those in C (see above). I am using preallocation to speed things up: 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 21 Jan, 2013 11:13:08 Message: 3 of 13 
Hi 
Subject: Problem using horzcat with index vectors in a for loop From: Bruno Luong Date: 21 Jan, 2013 13:06:08 Message: 4 of 13 
"Thomas " <thomas.seers@postgrad.manchester.ac.uk> wrote in message <kdhu6v$o6p$1@newscl01ah.mathworks.com>... 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 21 Jan, 2013 21:56:08 Message: 5 of 13 
Hi Bruno 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 21 Jan, 2013 22:09:09 Message: 6 of 13 
Update: the problem was a syntax error: it should have read: 
Subject: Problem using horzcat with index vectors in a for loop From: Bruno Luong Date: 21 Jan, 2013 23:41:09 Message: 7 of 13 
"Thomas " <thomas.seers@postgrad.manchester.ac.uk> wrote in message <kdkdho$pk3$1@newscl01ah.mathworks.com>... 
Subject: Problem using horzcat with index vectors in a for loop From: nl.doc@arcor.de Date: 22 Jan, 2013 10:18:46 Message: 8 of 13 
Does the following line execute the correct task? 
Subject: Problem using horzcat with index vectors in a for loop From: Bruno Luong Date: 22 Jan, 2013 10:31:08 Message: 9 of 13 
nl.doc@arcor.de wrote in message <7db9a2870e77436794e1a7e73a20411c@googlegroups.com>... 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 22 Jan, 2013 11:37:08 Message: 10 of 13 
Apologies for the lack of clarity. D is equal to C C. The concatenation of matching rows from A and B was only needed to tell me if INTERSECT would give me the correct locations of non matching data (i.e. ind1,..,n / x1,..,n) that was originally stored in the same rows as the image coordinates (i.e. A and B which does contain some matching data). I was trying to arrive at a point where I could retrieve data which is non matching from column vectors of the same length as A and B (this is what the second bit was about). However, I have managed to work through to this point in the end. Sorry again. I am quite new to programming, so I get stuck on syntax quite a bit. 
Subject: Problem using horzcat with index vectors in a for loop From: Bruno Luong Date: 22 Jan, 2013 11:45:09 Message: 11 of 13 
That's the reason we keep ask for meaningful and short example when a specific question is asked. If A and B have non matching columns, you should be provided in the example. It is much better than 1000 words. 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 22 Jan, 2013 15:51:08 Message: 12 of 13 
Yes, you are right. This is an unnecessary step. I only need the indices from intersect to concatenate the nonmatching components of my data stored in equivalent length vectors. I have now achieved this using 
Subject: Problem using horzcat with index vectors in a for loop From: Thomas Date: 22 Jan, 2013 16:16:09 Message: 13 of 13 
Yes, apologies again for my lack of clarity. 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.