2
$\begingroup$

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?

$\endgroup$

closed as off-topic by Daniel Lichtblau, m_goldberg, eyorble, MarcoB, Coolwater May 4 '18 at 7:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, eyorble, MarcoB, Coolwater
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    $\begingroup$ tab = Table[A v/t, {t, {4, 2, 5}}, {v, {5, 7, 4, 8, 0, 5}}]. $\endgroup$ – Henrik Schumacher May 3 '18 at 15:28
1
$\begingroup$

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}}*)
$\endgroup$
2
$\begingroup$
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}}

$\endgroup$
  • $\begingroup$ thank you guys i appreciate your help $\endgroup$ – Rabia May 4 '18 at 9:39
  • $\begingroup$ @rabia, my pleasure. Welcome to mma.se. $\endgroup$ – kglr May 4 '18 at 9:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.