Prev: Training of neural network using genetic algorithm
Next: PSO toolbox for latest Matlab versions
From: Walter Roberson on 19 May 2010 13:48 Marios Karaoulis wrote: > I have a strange filling that when i get values from a 3d matrix, is > somehow slow, Am I wrong? It can be fast: for example, A(:,:,5) is as fast as B(:,:) . However, A(:,5,:) or A(5,:,:) would likely be slower than B(:,:) .
From: James Tursa on 19 May 2010 14:53 Marios Karaoulis <marios.karaoulis(a)gmail.com> wrote in message <765a997a-a340-4aa2-8bd7-0e18cd24b636(a)23g2000pre.googlegroups.com>... > I have a strange filling that when i get values from a 3d matrix, is > somehow slow, Am I wrong? Again, I would stress that the overall answer for speed or efficiency depends on several factors, such as how you are creating/importing the original data, and how you use it downstream in your code. Unless you provide us with these details, we cannot give you a definitive answer. The best answer might be individual matrices, or 3D arrays, or cell arrays, or ... etc. etc. etc. James Tursa
From: Mark Shore on 19 May 2010 16:57 Marios Karaoulis <marios.karaoulis(a)gmail.com> wrote in message <d2e2ff8c-721e-4525-8354-538cf84211d8(a)z13g2000prh.googlegroups.com>... > Hi, which of the following is faster. > I have two options. > > > for i=1:100 > for j=1 to 20.000 > Calculate lala 8X8 matrix > use values of lala matrix > end > end > > or calculate once lala and store it as a 3d matrix like > lala(8,8,20000) and > for i=100 > use values from lala matrix > end > > I am doing some testes and I can't decide if it is better to have free > memory or reduce calculations Stepping back from the sound advice already offered, I assume you're familiar with the simple tic, toc timing commands? It's not entirely clear from your post whether the 8x8 array is the same or different for all 20000 cases. And presumably the calculations involved may be quite different depending on how you derive the array. On my computer, calculation time increases from 'zeros' to 'ones' to 'eye' to 'rand' and presumably upwards for more complex calculations. If you had a computationally-intensive function to generate only once, then storing it would probably be better, e.g. B=repmat(A,[1,1,20000]) But an 8x8x20000 array can't really be considered large by any standards now.
From: Rune Allnor on 19 May 2010 17:30 On 19 Mai, 18:55, Marios Karaoulis <marios.karaou...(a)gmail.com> wrote: > once lala and store it as a 3d matrix like I was going to say that it is a bad idea using command names for variables, but LALA is gone (R2006a)... Does anyone know when those things disappeared from matlab? Rune
From: fabio freschi on 24 May 2010 03:50 Given that I agree with those who say that computational effort strictly depends on what you are exactly doing, I usually avoid to store multiple 2d matrices as a 3d matrix, but I put them in a cell array. This allows to do matrix operations without reshaping the matrix Fabio
First
|
Prev
|
Pages: 1 2 Prev: Training of neural network using genetic algorithm Next: PSO toolbox for latest Matlab versions |