MATLAB: Creating a loop to search for matching values in two matrices

loopmultiply cells

I have two csv files. A is 55473 x 10 and B is 484 x 3. I want to create a loop that goes through column 5 in A, and when the value in the cell equals a value in column 1 in B, i want to multiply it by column 2 and column 3 of the same row in B. I want to repeat this for all values in column 5 of A.

Best Answer

You can do it without a for loop
[ii,jj]=ismember(A(:,5),B(:,1));
id=nonzeros(jj);
A(ii,5)=A(ii,5).*B(id,2).*B(id,3);