<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980</link>
    <title>MATLAB Central Newsreader - Issue with horzcat</title>
    <description>Feed for thread: Issue with horzcat</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 14 Apr 2009 03:38:01 -0400</pubDate>
      <title>Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642468</link>
      <author>Jeff </author>
      <description>I am trying to concatenate 2 matrices horizontally. I have tried doing this two ways&lt;br&gt;
&lt;br&gt;
ortPMat = [ortPMat' newPoint]&lt;br&gt;
&lt;br&gt;
and&lt;br&gt;
&lt;br&gt;
ortPMat = horzcat(ortPMat',newPoint)&lt;br&gt;
&lt;br&gt;
either way I get the error message&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;nbsp;same number of rows.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&lt;br&gt;
However, the dimensions of the matrices are 2X51 and 2X1 so they have the same number of rows. I even have the program display the size of each matrix so I can be absolutely sure. What am I missing?&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;
Jeff</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 03:49:02 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642470</link>
      <author>John Ramshur</author>
      <description>ortPMat=[ortPMat, newPoint]&lt;br&gt;
&lt;br&gt;
&quot;Jeff &quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs10ep$1vr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I am trying to concatenate 2 matrices horizontally. I have tried doing this two ways&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ortPMat = [ortPMat' newPoint]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ortPMat = horzcat(ortPMat',newPoint)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; either way I get the error message&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; horzcat&lt;br&gt;
&amp;gt; All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;gt;  same number of rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;gt;     ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, the dimensions of the matrices are 2X51 and 2X1 so they have the same number of rows. I even have the program display the size of each matrix so I can be absolutely sure. What am I missing?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jeff</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 03:52:01 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642472</link>
      <author>Matt Fig</author>
      <description>Since you give the dimensions, I will give it a try:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; ortPMat = rand(2,51);&lt;br&gt;
&amp;gt;&amp;gt; newPoint = rand(2,1);&lt;br&gt;
&amp;gt;&amp;gt; horzcat(ortPMat,newPoint);&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
No problem.  Why are you taking the transpose?</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 15:36:01 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642628</link>
      <author>Jeff </author>
      <description>&quot;Matt Fig&quot; &amp;lt;spamanon@yahoo.com&amp;gt; wrote in message &amp;lt;gs1191$q0a$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Since you give the dimensions, I will give it a try:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; ortPMat = rand(2,51);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; newPoint = rand(2,1);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; horzcat(ortPMat,newPoint);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; No problem.  Why are you taking the transpose?&lt;br&gt;
&lt;br&gt;
Well ortPmat is a 51X2 matrix so I have to take the transpose to make it 2X51. I don't know a lot of the in depth details of Matlab but transposing a matrix AFTER I have matlab output its size affects the size that is put out (at least that is what was happening last night). Thanks a lot for your help&lt;br&gt;
&lt;br&gt;
Jeff</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 17:10:04 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642655</link>
      <author>Matt </author>
      <description>&quot;Jeff &quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2ah1$ff4$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Matt Fig&quot; &amp;lt;spamanon@yahoo.com&amp;gt; wrote in message &amp;lt;gs1191$q0a$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Since you give the dimensions, I will give it a try:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; ortPMat = rand(2,51);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; newPoint = rand(2,1);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; horzcat(ortPMat,newPoint);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; No problem.  Why are you taking the transpose?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Well ortPmat is a 51X2 matrix so I have to take the transpose to make it 2X51. I don't know a lot of the in depth details of Matlab but transposing a matrix AFTER I have matlab output its size affects the size that is put out (at least that is what was happening last night). Thanks a lot for your help&lt;br&gt;
-----------------&lt;br&gt;
&lt;br&gt;
At this point, one can only assume that the efforts you made to determine the actual dimensions of the matrices were unsuccessful. Something may have happened to change the matrices between the time when you displayed them and the line where your code crashes.&lt;br&gt;
&lt;br&gt;
The thing to do is to type&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;dbstop if error&lt;br&gt;
&lt;br&gt;
and then rerun the code. When the code crashes, you will get the K&amp;gt;&amp;gt; prompt at which point you should type&lt;br&gt;
&lt;br&gt;
K&amp;gt;&amp;gt;whos ortPMat newPoint&lt;br&gt;
&lt;br&gt;
This will display the matrices' dimensions at the actual point in the code where the crash occurs.</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 17:50:18 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642668</link>
      <author>Jeff Hajewski</author>
      <description>&quot;Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &amp;lt;gs2g1c$k4g$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jeff &quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2ah1$ff4$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Matt Fig&quot; &amp;lt;spamanon@yahoo.com&amp;gt; wrote in message &amp;lt;gs1191$q0a$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Since you give the dimensions, I will give it a try:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&amp;gt; ortPMat = rand(2,51);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&amp;gt; newPoint = rand(2,1);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&amp;gt; horzcat(ortPMat,newPoint);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; No problem.  Why are you taking the transpose?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Well ortPmat is a 51X2 matrix so I have to take the transpose to make it 2X51. I don't know a lot of the in depth details of Matlab but transposing a matrix AFTER I have matlab output its size affects the size that is put out (at least that is what was happening last night). Thanks a lot for your help&lt;br&gt;
&amp;gt; -----------------&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; At this point, one can only assume that the efforts you made to determine the actual dimensions of the matrices were unsuccessful. Something may have happened to change the matrices between the time when you displayed them and the line where your code crashes.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The thing to do is to type&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;dbstop if error&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and then rerun the code. When the code crashes, you will get the K&amp;gt;&amp;gt; prompt at which point you should type&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; K&amp;gt;&amp;gt;whos ortPMat newPoint&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This will display the matrices' dimensions at the actual point in the code where the crash occurs.&lt;br&gt;
&lt;br&gt;
I did just as you said and it still says the dimensions are what I thought. Here is what Matlab said&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;nbsp;same number of rows.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&lt;br&gt;
45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;Name           Size                    Bytes  Class&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;newPoint       2x1                        16  double array&lt;br&gt;
&amp;nbsp;&amp;nbsp;ortPmat        2x51                      816  double array&lt;br&gt;
&lt;br&gt;
Grand total is 104 elements using 832 bytes&lt;br&gt;
&lt;br&gt;
This error doesn't make sense to me because they have the same number of rows.&lt;br&gt;
&lt;br&gt;
Jeff</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 18:03:40 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642675</link>
      <author>Matt Fig</author>
      <description>&quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &lt;br&gt;
&amp;gt; I did just as you said and it still says the dimensions are what I thought. Here is what Matlab said&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; horzcat&lt;br&gt;
&amp;gt; All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;gt;  same number of rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;gt;     ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;gt;   Name           Size                    Bytes  Class&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   newPoint       2x1                        16  double array&lt;br&gt;
&amp;gt;   ortPmat        2x51                      816  double array&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Grand total is 104 elements using 832 bytes&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This error doesn't make sense to me because they have the same number of rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Jeff&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Looks like we are back to post number 3.  </description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 18:06:02 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642679</link>
      <author>Matt </author>
      <description>&quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2icq$b0m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; 45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;gt;   Name           Size                    Bytes  Class&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   newPoint       2x1                        16  double array&lt;br&gt;
&amp;gt;   ortPmat        2x51                      816  double array&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Grand total is 104 elements using 832 bytes&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This error doesn't make sense to me because they have the same number of rows.&lt;br&gt;
&lt;br&gt;
Yes, it does make sense. In a previous post you told us that ortPmat was 51x2, which necessitated the transpose. The above output contradicts this, however. It says that ortPmat is really 2x51. So, it makes perfect sense that ortPmat' is not compatible with newPoint for concatenation.</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 18:25:03 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642684</link>
      <author>Jeff Hajewski</author>
      <description>&quot;Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &amp;lt;gs2jaa$gv1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2icq$b0m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; &amp;gt; K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;gt; &amp;gt;   Name           Size                    Bytes  Class&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;   newPoint       2x1                        16  double array&lt;br&gt;
&amp;gt; &amp;gt;   ortPmat        2x51                      816  double array&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Grand total is 104 elements using 832 bytes&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; This error doesn't make sense to me because they have the same number of rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes, it does make sense. In a previous post you told us that ortPmat was 51x2, which necessitated the transpose. The above output contradicts this, however. It says that ortPmat is really 2x51. So, it makes perfect sense that ortPmat' is not compatible with newPoint for concatenation.&lt;br&gt;
&lt;br&gt;
I took the transpose out and reran the program and here is the output&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;nbsp;same number of rows.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&lt;br&gt;
45      ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;Name           Size                    Bytes  Class&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;newPoint       2x1                        16  double array&lt;br&gt;
&amp;nbsp;&amp;nbsp;ortPmat       52x2                       832  double array&lt;br&gt;
&lt;br&gt;
Grand total is 106 elements using 848 bytes&lt;br&gt;
&lt;br&gt;
The error is in the same line of the code and for the exact same reason. Thanks for your patience. Matt Fig I didn't mean to ignore your post &lt;br&gt;
&lt;br&gt;
Jeff</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 18:30:20 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642688</link>
      <author>Matt Fig</author>
      <description>Is that line the ONLY place you took the transpose off?</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 18:35:02 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642689</link>
      <author>Matt </author>
      <description>&quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2kdv$k1j$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &amp;lt;gs2jaa$gv1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs2icq$b0m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;   Name           Size                    Bytes  Class&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;   newPoint       2x1                        16  double array&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;   ortPmat        2x51                      816  double array&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Grand total is 104 elements using 832 bytes&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; This error doesn't make sense to me because they have the same number of rows.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Yes, it does make sense. In a previous post you told us that ortPmat was 51x2, which necessitated the transpose. The above output contradicts this, however. It says that ortPmat is really 2x51. So, it makes perfect sense that ortPmat' is not compatible with newPoint for concatenation.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I took the transpose out and reran the program and here is the output&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; horzcat&lt;br&gt;
&amp;gt; All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;gt;  same number of rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;gt;     ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 45      ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&amp;gt; K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;gt;   Name           Size                    Bytes  Class&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   newPoint       2x1                        16  double array&lt;br&gt;
&amp;gt;   ortPmat       52x2                       832  double array&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Grand total is 106 elements using 848 bytes&lt;br&gt;
&lt;br&gt;
You made more changes than what you're telling us. If all you did was change line 45 of buildCurve by removing the tranpose, why is ortPmat now of different dimensions than before?&lt;br&gt;
&lt;br&gt;
In any case, there is still no mystery as to why the crash occurred. Since ortPmat has 52 rows (now) and newPoint only has 2 rows, it is clear that they cannot be horizontally concatenated. </description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 21:51:01 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642724</link>
      <author>Jeff Hajewski</author>
      <description>&quot;If all you did was change line 45 of buildCurve by removing the tranpose, why is ortPmat now of different dimensions than before?&quot;&lt;br&gt;
&lt;br&gt;
That is the whole reason I started this post to begin with-- it does not make any sense. &lt;br&gt;
&lt;br&gt;
That transpose is the ONLY change I made. If you want I can post the entire program. I am not making more changes than I am telling you.</description>
    </item>
    <item>
      <pubDate>Tue, 14 Apr 2009 22:29:01 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642738</link>
      <author>Matt </author>
      <description>&quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs30g5$dr8$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;If all you did was change line 45 of buildCurve by removing the tranpose, why is ortPmat now of different dimensions than before?&quot;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That is the whole reason I started this post to begin with-- it does not make any sense. &lt;br&gt;
-------&lt;br&gt;
&lt;br&gt;
The problem you describe now is not the problem you described in your original post. In the original post, you claimed that horzcat was failing to concatenate two matrices which by rights it ought to be able to. However, it is now  clear that the two matrices passed to horzcat were never of compatible sizes for this concatenation to be possible. &lt;br&gt;
&lt;br&gt;
If there is a problem, horzcat() is not the likely suspect. For whatever reason, the matrices are not the shape you expect by the time they are ready to be passed to horzcat. The change in shape is happening at some previous point in your code.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; That transpose is the ONLY change I made. If you want I can post the entire program. I am not making more changes than I am telling you.&lt;br&gt;
--------&lt;br&gt;
&lt;br&gt;
OK. Post 2 versions. The one before the change and the one after.</description>
    </item>
    <item>
      <pubDate>Wed, 15 Apr 2009 00:11:02 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642746</link>
      <author>Jeff Hajewski</author>
      <description>Here is the code before taking away the transpose:&lt;br&gt;
&lt;br&gt;
function buildCurve(X,Y)&lt;br&gt;
mx = mean(X);&lt;br&gt;
my = mean(Y);&lt;br&gt;
Xtrans = X - mx;&lt;br&gt;
Ytrans = Y - my;&lt;br&gt;
&lt;br&gt;
[theta,rho]=cart2pol(Xtrans,Ytrans);&lt;br&gt;
&lt;br&gt;
%theta = mod(theta, 2*pi);&lt;br&gt;
&lt;br&gt;
%Sort polar coord's so angles are in ascending order.&lt;br&gt;
Pmatrix = [theta rho] %2xN matrix of polar coord's.&lt;br&gt;
Pmatrix2 = Pmatrix.'; %Transpose, giving Nx2 matrix,col1=thetas &amp; col2=rhos.&lt;br&gt;
ortPmat = sortrows(Pmatrix2); %Sorts coord's ascendingly by angle.&lt;br&gt;
&lt;br&gt;
%Shift thetas by -2*pi &amp; +2*pi, emphasize periodicity.&lt;br&gt;
NegCopyPmat = ortPmat;&lt;br&gt;
NegCopyPmat(:,1) = NegCopyPmat(:,1) - 2*pi;&lt;br&gt;
PosCopyPmat = ortPmat;&lt;br&gt;
PosCopyPmat(:,1) = PosCopyPmat(:,1) + 2*pi;&lt;br&gt;
%Concatenate transposes of these matrices.&lt;br&gt;
periodPmat = [NegCopyPmat.' ortPmat.' PosCopyPmat.'];&lt;br&gt;
periodPmat = periodPmat.'; %Transpose back.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
for j =2:(length(theta)-1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;thetag(j-1) = -theta(j);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
theta;&lt;br&gt;
thetag = thetag';&lt;br&gt;
%define &lt;br&gt;
&lt;br&gt;
for i=1:length(thetag)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newRho = spline(periodPmat(:,1),periodPmat(:,2),thetag(i));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPoint = [thetag(i)'; newRho];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Adds new point to initial Point matrix.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size(ortPmat)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size(newPoint)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = sortrows(ortPmat.');&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Shifts new ortPmat for periodicity.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NegCopyPmat = ortPmat;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NegCopyPmat(:,1) = NegCopyPmat(:,1) - 2*pi;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PosCopyPmat = ortPmat;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PosCopyPmat(:,1) = PosCopyPmat(:,1) + 2*pi;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Concatenate transposes of these matrices.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;periodPmat = [NegCopyPmat.' ortPmat.' PosCopyPmat.'];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;periodPmat = periodPmat.'; %Transpose back.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
[newX newY] = pol2cart(THETA,RHO);&lt;br&gt;
newX = newX + mx;&lt;br&gt;
newY = newY + my;&lt;br&gt;
plot(newX,newY)&lt;br&gt;
------------------------------------------------------------------------------------&lt;br&gt;
Matlab Output&lt;br&gt;
-----------------------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;nbsp;same number of rows.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
&lt;br&gt;
45      ortPmat = horzcat(ortPmat', newPoint);&lt;br&gt;
K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;Name           Size                    Bytes  Class&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;newPoint       2x1                        16  double array&lt;br&gt;
&amp;nbsp;&amp;nbsp;ortPmat        2x51                      816  double array&lt;br&gt;
&lt;br&gt;
Grand total is 104 elements using 832 bytes&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-------------------------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Here is the code after taking away the transpose:&lt;br&gt;
&lt;br&gt;
function buildCurve(X,Y)&lt;br&gt;
&lt;br&gt;
mx = mean(X);&lt;br&gt;
my = mean(Y);&lt;br&gt;
Xtrans = X - mx;&lt;br&gt;
Ytrans = Y - my;&lt;br&gt;
&lt;br&gt;
[theta,rho]=cart2pol(Xtrans,Ytrans);&lt;br&gt;
&lt;br&gt;
%theta = mod(theta, 2*pi);&lt;br&gt;
&lt;br&gt;
%Sort polar coord's so angles are in ascending order.&lt;br&gt;
Pmatrix = [theta rho] %2xN matrix of polar coord's.&lt;br&gt;
Pmatrix2 = Pmatrix.'; %Transpose, giving Nx2 matrix,col1=thetas &amp; col2=rhos.&lt;br&gt;
ortPmat = sortrows(Pmatrix2); %Sorts coord's ascendingly by angle.&lt;br&gt;
&lt;br&gt;
%Shift thetas by -2*pi &amp; +2*pi, emphasize periodicity.&lt;br&gt;
NegCopyPmat = ortPmat;&lt;br&gt;
NegCopyPmat(:,1) = NegCopyPmat(:,1) - 2*pi;&lt;br&gt;
PosCopyPmat = ortPmat;&lt;br&gt;
PosCopyPmat(:,1) = PosCopyPmat(:,1) + 2*pi;&lt;br&gt;
%Concatenate transposes of these matrices.&lt;br&gt;
periodPmat = [NegCopyPmat.' ortPmat.' PosCopyPmat.'];&lt;br&gt;
periodPmat = periodPmat.'; %Transpose back.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
for j =2:(length(theta)-1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;thetag(j-1) = -theta(j);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
theta;&lt;br&gt;
thetag = thetag';&lt;br&gt;
%define &lt;br&gt;
&lt;br&gt;
for i=1:length(thetag)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newRho = spline(periodPmat(:,1),periodPmat(:,2),thetag(i));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPoint = [thetag(i)'; newRho];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Adds new point to initial Point matrix.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size(ortPmat)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size(newPoint)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = sortrows(ortPmat.');&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Shifts new ortPmat for periodicity.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NegCopyPmat = ortPmat;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NegCopyPmat(:,1) = NegCopyPmat(:,1) - 2*pi;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PosCopyPmat = ortPmat;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PosCopyPmat(:,1) = PosCopyPmat(:,1) + 2*pi;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%Concatenate transposes of these matrices.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;periodPmat = [NegCopyPmat.' ortPmat.' PosCopyPmat.'];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;periodPmat = periodPmat.'; %Transpose back.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
[newX newY] = pol2cart(THETA,RHO);&lt;br&gt;
newX = newX + mx;&lt;br&gt;
newY = newY + my;&lt;br&gt;
plot(newX,newY)&lt;br&gt;
--------------------------------------------------------------------------------------------------------------&lt;br&gt;
Matlab Output&lt;br&gt;
--------------------------------------------------------------------------------------------------------------&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
All matrices on a row in the bracketed expression must have the &lt;br&gt;
&amp;nbsp;same number of rows.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; buildCurve at 45&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&lt;br&gt;
45      ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
K&amp;gt;&amp;gt; whos ortPmat newPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;Name           Size                    Bytes  Class&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;newPoint       2x1                        16  double array&lt;br&gt;
&amp;nbsp;&amp;nbsp;ortPmat       52x2                       832  double array&lt;br&gt;
&lt;br&gt;
Grand total is 106 elements using 848 bytes</description>
    </item>
    <item>
      <pubDate>Wed, 15 Apr 2009 01:52:01 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#642753</link>
      <author>Jiro Doke</author>
      <description>&quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs38mm$4pv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Here is the code after taking away the transpose:&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
*&amp;lt;snip&amp;gt;*&lt;br&gt;
&lt;br&gt;
&amp;gt;     ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&amp;gt;     ortPmat = sortrows(ortPmat.');&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Okay, I think the problem happens here (and the fact that this runs in a loop, recursively). After you do &quot;horzcat&quot;, you transpose it to do &quot;sortrows&quot; (I assume you want to sort by columns). You should transpose it back:&lt;br&gt;
&lt;br&gt;
ortPmat = sortrows(ortPmat.').';&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Then, of course, you may have to fix the rest of the code below. *This may not be completely accurate, but here goes*&lt;br&gt;
&lt;br&gt;
NegCopyPmat = ortPmat;&lt;br&gt;
NegCopyPmat(1,:) = NegCopyPmat(1,:) - 2*pi;&lt;br&gt;
PosCopyPmat = ortPmat;&lt;br&gt;
PosCopyPmat(1,:) = PosCopyPmat(1,:) + 2*pi;&lt;br&gt;
&lt;br&gt;
%Concatenate transposes of these matrices.&lt;br&gt;
periodPmat = [NegCopyPmat ortPmat PosCopyPmat];&lt;br&gt;
periodPmat = periodPmat; %Transpose back.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
-----&lt;br&gt;
jiro</description>
    </item>
    <item>
      <pubDate>Thu, 16 Apr 2009 00:39:02 -0400</pubDate>
      <title>Re: Issue with horzcat</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/248980#643036</link>
      <author>Jeff Hajewski</author>
      <description>Very nice. Thanks a lot- that solved the problem&lt;br&gt;
&lt;br&gt;
Jeff&lt;br&gt;
&lt;br&gt;
&quot;Jiro Doke&quot; &amp;lt;jiro.doke@mathworks.com&amp;gt; wrote in message &amp;lt;gs3ek1$7sk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jeff Hajewski&quot; &amp;lt;jhajewsk@indiana.edu&amp;gt; wrote in message &amp;lt;gs38mm$4pv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Here is the code after taking away the transpose:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; *&amp;lt;snip&amp;gt;*&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;     ortPmat = horzcat(ortPmat, newPoint);&lt;br&gt;
&amp;gt; &amp;gt;     ortPmat = sortrows(ortPmat.');&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Okay, I think the problem happens here (and the fact that this runs in a loop, recursively). After you do &quot;horzcat&quot;, you transpose it to do &quot;sortrows&quot; (I assume you want to sort by columns). You should transpose it back:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ortPmat = sortrows(ortPmat.').';&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Then, of course, you may have to fix the rest of the code below. *This may not be completely accurate, but here goes*&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; NegCopyPmat = ortPmat;&lt;br&gt;
&amp;gt; NegCopyPmat(1,:) = NegCopyPmat(1,:) - 2*pi;&lt;br&gt;
&amp;gt; PosCopyPmat = ortPmat;&lt;br&gt;
&amp;gt; PosCopyPmat(1,:) = PosCopyPmat(1,:) + 2*pi;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; %Concatenate transposes of these matrices.&lt;br&gt;
&amp;gt; periodPmat = [NegCopyPmat ortPmat PosCopyPmat];&lt;br&gt;
&amp;gt; periodPmat = periodPmat; %Transpose back.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -----&lt;br&gt;
&amp;gt; jiro</description>
    </item>
  </channel>
</rss>

