2

Suppose I have $t=4, 2, 5$ and $v=5, 7, 4, 8, 0, 5$ and $equ=A v/t$. I would like to calculate $equ$ at a single value of $t$ by using all $v$ values and then move to next value of $t$.

How can I make a loop for this?

David G. Stork
  • 41,180
  • 3
  • 34
  • 96
Rabia
  • 33
  • 4

2 Answers2

2
t = {4, 2, 5} ; v = {5, 7, 4, 8, 0, 5};
A Outer[#2/# &, t, v] (* or *)
A Outer[Divide, v, t] // Transpose

{{(5 A)/4, (7 A)/4, A, 2 A, 0, (5 A)/4}, {(5 A)/2, (7 A)/2, 2 A, 4 A, 0, (5 A)/2}, {A, (7 A)/5, (4 A)/5, (8 A)/5, 0, A}}

kglr
  • 394,356
  • 18
  • 477
  • 896
1

Another simple way using Map:

 t = {4, 2, 5}; v = {5, 7, 4, 8, 0, 5};
 equ = A (v/#) & /@ t

(*{{(5 A)/4, (7 A)/4, A, 2 A, 0, (5 A)/4}, {(5 A)/2, (7 A)/2, 
 2 A, 4 A, 0, (5 A)/2}, {A, (7 A)/5, (4 A)/5, (8 A)/5, 0, A}}*)
Subho
  • 1,534
  • 1
  • 8
  • 18