102k views
5 votes
A = [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 33 34 35 36 37 38 39 40]

b = [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 43 45 47 49 50 54 59 60]

In MATLAB, only using fully-vectorised code (ie. no loops) divide A by B element by element.

User FZs
by
6.6k points

1 Answer

0 votes

Answer:


C = a./b

Step-by-step explanation:

In MATLAB, the following command:


C = A./B

Performs the element by elemet division of A and B. This comand is called Right-array division.

So, in your case, we could divide A by B element by element, only using fully-vectorised code (ie. no loops), with the following code:


a = [2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 33 34 35 36 37 38 39 40];</p><p>b = [1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 43 45 47 49 50 54 59 60];</p><p>C = a./b;

C would be the element by element division of A and B, with no loops.

User Nikolay Shmyrev
by
6.4k points