How to get all combinations of PRODUCTS between two array elements?

Hi,
Let's say I have two arrays.
A =[5 6 8 9 7];
B= [3 4 5];
I need all combinations of elements of A* elements of B. for examle, 5*3, 5*4, 5*5, 6*3, 6*4,...and so on Thanks.

 Accepted Answer

More Answers (1)

A(:).*B(:).'
If you can guarantee that both are row vectors then either
A.'. * B
or
A .* B.'
The result will be a 2d array, length() of one by length() of the other.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 9 Jun 2022

Commented:

on 10 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!