[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
efficient way to process array of vectors?
From: |
DushanM |
Subject: |
efficient way to process array of vectors? |
Date: |
Tue, 6 Nov 2007 10:09:43 -0600 |
User-agent: |
MacSOUP/2.8.1 (Mac OS X version 10.4.10 (x86)) |
I'm still learning Octave, so this question may be pretty basic, but
so far I haven't figured the answer.
I'd like to find an efficient way in Ocatve to carry out the same
set of vector operations for every vector element of a cell array.
If (j,k) are indices and A,B are 3-vectors, an obvious way is to use
loops:
for j=1:jmax
for k=1:kmax
determine A = [Ax(j,k); Ay(j,k); Az(j,k)]
determine B = [Bx(j,k); By(j,k); Bz(j,k)]
compute vector C from A and B
endfor
endfor
Is it possible to use cell arrays with indices (j,k) and vectors A,B
as cell elements, so that
carrayA{j,k} = A
carrayB{j,k} = B
where A and B are determined anew for each (j,k)? In other words,
could I perform vector operations on A and B, and have Octave auto-
matically (and efficiently) do the loops over j and k?
I could define a 3-D array carrA(j,k,1:3) with the last index re-
fering to the three vector components, but then how do I treat those
three together as a vector?
- Dushan Mitrovich
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- efficient way to process array of vectors?,
DushanM <=