MATLAB: I have 4 columns of (256×4 double) type.

adding separated columnsmatrix array

I want to add column 1 with 3 and column 4 with 2 and need to store results in two columns. In first column it should save the result of 1 and 3 and in second column it should save 2 and 4 result. one more thing i want to add column 1 with 3 randomly.Like 1st index of column 1 need to add with any index of column 3. i don't want to add these columns with similar index

Best Answer

B = A(:,1:2)+A(:,3:4);