Thread Subject: Accessing random sections of 3D matrices- why does execution time vary widely?

Subject: Accessing random sections of 3D matrices- why does execution time vary widely?

From: Susan Wardle

Date: 3 Jul, 2009 01:49:01

Message: 1 of 1

Hi,

I've been stuck on this problem for a while, and I haven't found the solution in the documentation, so I thought I'd try the experts...

The problem is that 2 parts of my code have widely variable execution times, and I cannot see the reason for this.
(I need the shortest execution time possible because I am creating movies to show participants in a Psychology experiment- the matrix contains the pixel values to draw patterns on the screen)
---------------------------------------------------------------------------------------------
1. I am using large double precision (300 x 300 x 300) 3D matrices, and I want to access random segments of 100 consecutive slices in the third dimension eg: (:,:,1:100).

Looping the line of code copied below 20 times produced a range of durations from 0.3-3.7 seconds.

Fmovie=FmovieWhole(:,:,ranf(n):ranf(n)+99);

FmovieWhole is the parent (300 x 300 x 300) matrix, randf is an array of random integers used to pick the starting index for the random slice, and Fmovie is the (300 x 300 x 100) slice (and it is preallocated initially for speed).
---------------------------------------------------------------------------------------------
2. This section of code varied from taking 1.3 - 4.7 seconds to execute when I ran it 20 times.
Vmovie is a 300 x 300 x 100 matrix and the code below changes the pixel values to adjust the contrast of the image. VLinContrast is a scaler.

    Vmovie=Vmovie./255; %normalise 0-1
    rms=std2(Vmovie); %rms contrast
    meanLum=mean2(Vmovie);
    Vmovie=Vmovie-meanLum;
    Vmovie=Vmovie.*(VLinContrast/rms) +meanLum;
    Vmovie=Vmovie.*255;

Perhaps these problems are related to how memory has been allocated?

My computer is a 1.8 GHz PowerPC Mac with 1GB RAM running Matlab R2007a

Any suggestions or detail about how Matlab stores 3D matrices in memory would be greatly appreciated!

thanks,

Susan

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
3d matrix Susan Wardle 2 Jul, 2009 21:49:06
memory Susan Wardle 2 Jul, 2009 21:49:06
storage Susan Wardle 2 Jul, 2009 21:49:06
execution time Susan Wardle 2 Jul, 2009 21:49:06
processing speed Susan Wardle 2 Jul, 2009 21:49:06
large matrices Susan Wardle 2 Jul, 2009 21:49:06
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com