<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'For Loop , Need Help' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'For Loop , Need Help' posted on the 'Matlab' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2010 Programmers Heaven</copyright>
    <pubDate>Mon, 15 Mar 2010 22:27:50 -0700</pubDate>
    <lastBuildDate>Mon, 15 Mar 2010 22:27:50 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>For Loop , Need Help</title>
      <link>http://www.programmersheaven.com/mb/ctocplusplustomatlab/408374/408374/for-loop--need-help/</link>
      <description>Hi&lt;br /&gt;
&lt;br /&gt;
I try to  use a block operation in a image 400x400. It works fine . Now if i use different image this code does not work. So please any one tell me how to add padding zeros using the for loop.&lt;br /&gt;
&lt;br /&gt;
We have  a function in matlab, but i want to use in this for loop same thing ,  please any one tell me how to do that .  my code &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;

I  = imread('5.jpg');
Block size (bk) = 50;
  for j = 1:bk:size(rgb,2)
         for i = 1:bk:size(rgb,1)
         block = gray(i:(i+(bk-1)), j:(j+(bk-1)));

/// do some operation 

      end
  end
 figure,imshow(z);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The above code works fine if the image size is divided by Block size, but if the image size if different , then there is a error like this &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
??? Index exceeds matrix dimensions.&lt;br /&gt;
&lt;br /&gt;
Error in ==&amp;gt; block_gradient at 12&lt;br /&gt;
         block = gray(i:(i+(bk-1)), j:(j+(bk-1)));&lt;br /&gt;
&lt;br /&gt;
So please any one help me to fix this . How to add padding inside this loop, so that this will work for all image.&lt;br /&gt;
&lt;br /&gt;
Thank You&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ctocplusplustomatlab/408374/408374/for-loop--need-help/</guid>
      <pubDate>Mon, 26 Oct 2009 19:56:43 -0700</pubDate>
      <category>Matlab</category>
    </item>
  </channel>
</rss>