From: Steven Lord on

"Vikas Bajpai" <vikas.bajpai87(a)gmail.com> wrote in message
news:b35aedf0-a2fe-43b8-a333-c5f03a215e67(a)u9g2000prm.googlegroups.com...
> On Apr 21, 8:09 pm, Walter Roberson <rober...(a)hushmail.com> wrote:
> > Vikas Bajpai wrote:
> > > let me try to explain the problem in some simpler way. Suppose I
> > > have an image and i am performing an operation using for loop on the
> > > image as a whole and the time comes out to be 2.55 seconds. Now I am
> > > using 4 for loops and implementing these for loops on four equal parts
> > > of the image and time comes out to be 0.11 second. Although this
> > > sounds unusual but I have this result but I don't know why this is
> > > happening.
> >
> > In addition to the other responses (e.g., talking about preallocation):
> >
> > You have not told us anything about what kind of processing you are
> > doing. There are some kinds of processing that take much more time as
> > they are applied to bigger problems. For example, anything involving
> > covariances or inverses or matrix division takes time that increases
> > with the square or cube or 4th power of the size of the matrix.
>
> sir I am only performing plus and minus operations, not more than that

Then it sounds like you're probably working with a very large image that
requires swapping in and out of memory and/or you're growing an array inside
a loop. You'll need to show us more about what exactly you're doing for us
to be able to help figure out if the cause of the slow performance is one of
those or something else.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ