double loops

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi,

I am new in Matlab and I have to creat a moving window to make calculations for my research. I did it with the help of double loop which looks like this:

for c=417:500
for j=1:c

    matrix(:,:,j,c)=y(:,j)*y(:,j)'-S(:,:,c)
 end
end
where "y" is 21 by 500 matrix of data, S is 21 by 21 by 500 matrix of data

The problem is that as "c" starts from 417, MATLAB first calculate 417 matrixes of "0" (number of "j") for 1:417 times (number of "c"). Only after that it starts to calculate the data that I need (for "c" equal from 417 to 500). Calculation of these first matrixes of "0" take long time, so does anybody know how to create a code which will start directly from 417 so I can speed up a process? 

Many thanks an advance,

Katerina  
0
Reply eipatova 10/16/2009 11:34:04 PM

See related articles to this posting


On Oct 16, 7:34=A0pm, "Ekaterina Ipatova" <eipat...@list.ru> wrote:
> Hi,
>
> I am new in Matlab and I have to creat a moving window to make calculatio=
ns for my research. I did it with the help of double loop which looks like =
this:
>
> for c=3D417:500
> for j=3D1:c
>
> =A0 =A0 matrix(:,:,j,c)=3Dy(:,j)*y(:,j)'-S(:,:,c)
> =A0end
> end
> where "y" is 21 by 500 matrix of data, S is 21 by 21 by 500 matrix of dat=
a
>
> The problem is that as "c" starts from 417, MATLAB first calculate 417 ma=
trixes of "0" (number of "j") for 1:417 times (number of "c"). Only after t=
hat it starts to calculate the data that I need (for "c" equal from 417 to =
500). Calculation of these first matrixes of "0" take long time, so does an=
ybody know how to create a code which will start directly from 417 so I can=
 speed up a process?
>
> Many thanks an advance,
>
> Katerina =A0

-------------------------------------------------------------------------
Katerina  :
I can't really tell what you're doing.  You have 2D and 3D matrices
and then end up with a 4D matrix.  Too complicated for me to figure
out.  I'm not that good at visualizing hyper-dimensional image space.
I don't know what that 4 dimensional array means.  Can you explain
what you want to do in words?  Do you want to do something like a
convolution or a sliding window type of filter?  As a wild guess,
maybe you can check out these functions:
bsxfun(), convn(), imfilter()
-ImageAnalyst
0
Reply imageanalyst (7622) 10/17/2009 12:38:52 AM
comp.soft-sys.matlab 203508 articles. 529 followers. Post

1 Replies
56 Views

Similar Articles

[PageSpeed] 4


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces: