2
$\begingroup$

I am trying to perform Bessel function computations of the form Jn(b*x) where n is the order of the Bessel function. I have three columns representing x, b and n. I wish to import this data into Mathematica and compute Jn(bx) and export the results back to either .csv or .dat formats where Jn(bx) will now be my 4th column. I got a very nice tutorial here but it is not particularly suited for what I am looking for. Your kind suggestions would be highly appreciated. My data is available here!

$\endgroup$
3
$\begingroup$
m = Import["bessel.xlsx"] // Transpose // Flatten[#, 1] & // 
  Delete[#, 1] &

This imports, the file, flattens it to a matrix and deletes the header row. You may need the complete path name if the data is not in the current directory. Then

Table[BesselJ[m[[i, 2]], m[[i, 1]] m[[i, 3]]], {i, Length[m]}]

{0.0349786, 0.0217276, 0.0136127, 0.0676302, 0.0527186, 0.0394126, 0.03222, 0.0256004, 0.0240566, 0.247746}
$\endgroup$
2
$\begingroup$

You can skip the header also with an import option. And instead of Table, you can also apply a functional approach with Apply (used as @@@ here):

data = Import["bessel.xlsx", "HeaderLines" -> 1][[1]];
f = {x, n, b} \[Function] BesselJ[n, b x];
f @@@ data
$\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.