0
votes

I have to two evenly sized very large vectors (columns) A and B. I would like to divide vector A by vector B. This will give me a large matrix AxB filled with zeros, except the last column. This column contains the values I'm interested in. When I simple divide the vectors in a Matlab script, I run out of memory. Probably because the matrix AxB becomes very large. Probably I can prevent this from happening by repeating the following:

  1. calculating the first row of matrix AxB

  2. filter the last value and put it into another vector C.

  3. delete the used row of matrix AxB

  4. redo step 1-4 for all rows in vector A

How can I make a loop which does this?

2
What is B^-1? Are you multiplying A by the element-wise inverse of B? – Jonas
Can you update your question with the code you are using to divide A by B – slayton

2 Answers

0
votes

You're question doesn't make it clear what you are trying to do, although it sounds like you want to do an element wise division.

Try:

C = A./B
0
votes

"Matrix product AxB" and "dividing vectors" are distinct operations. If we understood this correctly, what you do want to calculate is "C = last column from AxB", such that:

lastcolsel=zeros(size(B,2),1)
C=(A*B)*lastcolsel

If that code breaks your memory limit, recall that matrix product is associative (MxN)xP = Mx(NxP). Simplifying your example, we get:

lastcolsel=zeros(size(B,2),1)
simplifier=B*lastcolsel
C=A*simplifier