<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264412</link>
    <title>MATLAB Central Newsreader - Please take a look at this code and let me know what's wrong</title>
    <description>Feed for thread: Please take a look at this code and let me know what's wrong</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>Thu, 29 Oct 2009 05:55:04 -0400</pubDate>
      <title>Please take a look at this code and let me know what's wrong</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264412#690525</link>
      <author>Mike M</author>
      <description>Here's a &quot;problem&quot; I'm working on:&lt;br&gt;
m = input('Enter an integer m to represent the number of desired rows:')&lt;br&gt;
n = input('Enter an integer n to represent the number of desired columns:')&lt;br&gt;
A = zeros(m:n);&lt;br&gt;
for i = 1:m&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j = 1:n&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A(i,j) = linspace((i-1)*n+1, (i-1)*n+j, n);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
A&lt;br&gt;
It's supposed to create an m x n matrix that goes from 1:n by 1.  In other words, if you enter 3 for m and 3 for n, you should get:&lt;br&gt;
A = [1,2,3;4,5,6;7,8,9].  Entering 4 would do the same except to 16.  I'm definitely a newbie so I'm not seeing the error. </description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 06:46:57 -0400</pubDate>
      <title>Re: Please take a look at this code and let me know what's wrong</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264412#690533</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Mike M&quot; &amp;lt;mccain1976@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:hcbano$9kc$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Here's a &quot;problem&quot; I'm working on:&lt;br&gt;
&amp;gt; m = input('Enter an integer m to represent the number of desired rows:')&lt;br&gt;
&amp;gt; n = input('Enter an integer n to represent the number of desired &lt;br&gt;
&amp;gt; columns:')&lt;br&gt;
&amp;gt; A = zeros(m:n);&lt;br&gt;
&amp;gt; for i = 1:m&lt;br&gt;
&amp;gt;    for j = 1:n&lt;br&gt;
&amp;gt;        A(i,j) = linspace((i-1)*n+1, (i-1)*n+j, n);&lt;br&gt;
&amp;gt;    end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; A&lt;br&gt;
&amp;gt; It's supposed to create an m x n matrix that goes from 1:n by 1.  In other &lt;br&gt;
&amp;gt; words, if you enter 3 for m and 3 for n, you should get:&lt;br&gt;
&amp;gt; A = [1,2,3;4,5,6;7,8,9].  Entering 4 would do the same except to 16.  I'm &lt;br&gt;
&amp;gt; definitely a newbie so I'm not seeing the error.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
one way, use loop&lt;br&gt;
&lt;br&gt;
m = input('Enter an integer m to represent the number of desired rows:')&lt;br&gt;
n = input('Enter an integer n to represent the number of desired columns:')&lt;br&gt;
A=zeros(m,n);&lt;br&gt;
&lt;br&gt;
for i=1:m&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j=1:n&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A(i,j)=n*(i-1)+j;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
(could be done witout loop if you really want to)&lt;br&gt;
&lt;br&gt;
--Nasser</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 20:44:03 -0500</pubDate>
      <title>Re: Please take a look at this code and let me know what's wrong</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264412#692188</link>
      <author>Sebastian Arslanogullari</author>
      <description>Hi Mike&lt;br&gt;
As Nasser wrote, there are more elegant ways to solve this without a loop.&lt;br&gt;
A one-line example would be:&lt;br&gt;
A = shiftdim(reshape(1:m*n,n,m),1);&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Sebastian Arslanogullari&lt;br&gt;
&lt;br&gt;
&quot;Mike M&quot; &amp;lt;mccain1976@gmail.com&amp;gt; wrote in message &amp;lt;hcbano$9kc$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Here's a &quot;problem&quot; I'm working on:&lt;br&gt;
&amp;gt; m = input('Enter an integer m to represent the number of desired rows:')&lt;br&gt;
&amp;gt; n = input('Enter an integer n to represent the number of desired columns:')&lt;br&gt;
&amp;gt; A = zeros(m:n);&lt;br&gt;
&amp;gt; for i = 1:m&lt;br&gt;
&amp;gt;     for j = 1:n&lt;br&gt;
&amp;gt;         A(i,j) = linspace((i-1)*n+1, (i-1)*n+j, n);&lt;br&gt;
&amp;gt;     end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; A&lt;br&gt;
&amp;gt; It's supposed to create an m x n matrix that goes from 1:n by 1.  In other words, if you enter 3 for m and 3 for n, you should get:&lt;br&gt;
&amp;gt; A = [1,2,3;4,5,6;7,8,9].  Entering 4 would do the same except to 16.  I'm definitely a newbie so I'm not seeing the error. </description>
    </item>
  </channel>
</rss>

