user1766845
user1766845

Reputation: 1

Assign variable in mathematica

Can I ask for some help in the assigning of variables in my matematica module to solve for my PD function.

 PD[a_,l_]:= Module[(a=[x1,y1,P],l=[x2,y2]; PD.=P./(4*pi*((x2-x1)^2)+(y2-y1)^2))]

Upvotes: 0

Views: 618

Answers (1)

b.gatessucks
b.gatessucks

Reputation: 1242

Something like :

pd[a_, l_] :=  a[[3]]/(4 Pi ((l[[1]] - a[[1]])^2 + (l[[2]] - a[[2]])^2))

pd[{1, 2, 3}, {4, 5}]
(* 1/(24 \[Pi]) *)

You might also want to redefine your arguments; for instance :

pd2[r1_, r2_, p_] = p/(4 Pi EuclideanDistance[r1, r2]^2);

pd2[{1, 2}, {4, 5}, 3]
(* 1/(24 \[Pi]) *)

Upvotes: 1

Related Questions