structures, cells or high dimensional arrays
Mostra commenti meno recenti
Dear all,
I have to deal with arrays of dimension 4 or 5. So far, I can only think of 3 ways to represent such arrays.
- Using matrices only, the representation of the i-j-k-l-m can be written as A(i,j,k,l,m)
- using structures, it would be A(i).V(j,k,l,m)
- finally using cells, it is A{i}(j,k,l,m)
My problem is that I have non-vectorizable loops around those elements and I was wondering 1) which one of those representations has the greatest speed, 2) whether there are more efficient representations and 3) whether it is possible to accelerate operations involving such arrays.
Thanks, Patrick
Risposta accettata
Più risposte (1)
Patrick Mboma
il 24 Giu 2013
0 voti
1 Commento
Sean de Wolski
il 24 Giu 2013
Modificato: Sean de Wolski
il 24 Giu 2013
passing P, passes a reference to P and does not make a memory copy. Indexing into P using P(:,:) copies the memory into a new array. You can see this by:
Opening the task manager (Windows) and looking at performance -> physical memory usage.
Then run:
A = magic(10000);
You'll see a jump in memory. If you then run:
B = A;
No change, since B is merely a reference to A.
C = A(:,:)
It jumps again.
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!