0
$\begingroup$

This question was asked before (here), but I couldn't get the answers to work. I have a list of values

List1=Table[{theta,phi,f1[theta,phi]},{theta,0,Pi,Pi/10},{phi,0,2Pi,2Pi/10}]
List2=Table[{theta,phi,f2[theta,phi]},{theta,0,Pi,Pi/10},{phi,0,2Pi,2Pi/10}]
f=Table[{List1[[i,j,1]],List1[[i,j,2]],List1[[i,j,3]]^2+List2[[i,j,3]]^2},{i,1,Length[List1]},{j,1,Length[List1[[1]]]}]

Sample functions for f1 and f2:

f1[theta,phi]=Sin[3 theta]Cos[phi];
f2[theta,phi]=Cos[theta] Sin[phi];

How do I get SphericalPlot3D of f from this list? Any help would be appreciated. TIA!

$\endgroup$
4
  • $\begingroup$ What are the definitions of f1 and f2? $\endgroup$ – Bob Hanlon Feb 22 at 15:48
  • $\begingroup$ @BobHanlon They're complicated functions of theta and phi, which is why I didn't want to write them down. I just wanted a general way of getting to the SphericalPlot. $\endgroup$ – 123infinity Feb 22 at 16:26
  • $\begingroup$ You don't necessarily need to post your actual functions; however, you should include some simple examples. Either one person (you) goes through the effort of making up some functions or everyone who is willing to help you has to do it. $\endgroup$ – Bob Hanlon Feb 22 at 16:57
  • $\begingroup$ Okay, that makes sense. I'll edit it to include functions. Thanks. $\endgroup$ – 123infinity Feb 22 at 17:05
1
$\begingroup$
Clear["Global`*"]

f1[theta_, phi_] = Sin[3 theta] Cos[phi];
f2[theta_, phi_] = Cos[theta] Sin[phi];

List1 = Flatten[
   Table[{{theta, phi}, f1[theta, phi]}, {theta, 0, Pi, Pi/10}, {phi, 
     0, 2 Pi, 2 Pi/10}], 1];

List2 = Flatten[
   Table[{{theta, phi}, f2[theta, phi]}, {theta, 0, Pi, Pi/10}, {phi, 
     0, 2 Pi, 2 Pi/10}], 1];

funcs = Interpolation /@ {List1, List2}

enter image description here

SphericalPlot3D[Evaluate@Through[funcs[theta, phi]],
 {theta, 0, Pi}, {phi, 0, 2 Pi},
 PlotPoints -> 50,
 PlotLegends -> Automatic]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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