1
$\begingroup$

I am newbie here so maybe my question might seem pretty basic. My problem is this: I have four 4x6 tables with known values of which the user should use, within a function f, only one from each table each time so that a new table with values for f is created. However, there is something wrong in my code which i cannot understand. Any suggestions?

Consider $d=1$ and $ksi=1000$ for my function

TEg0 = {{4.493410, 7.725252, 10.904120  14.066190, 17.220750, 
   20.371300},
  {5.763460, 9.095012, 12.322940, 15.5146000, 18.689040, 21.853870},
  {6.987932, 10.417120, 13.698020, 16.923620, 20.121810, 23.304250},
  {8.182562, 11.704910, 15.039660, 18.301260, 21.525420, 24.727570}}

TEg1g0 = {{0.400000, 0.400000, 0.400000, 0.400000, 0.400000, 0.400000},
  {0.285714, 0.285714, 0.285714, 0.285729, 0.285716, 0.285729},
  {0.266667, 0.266667, 0.266667, 0.266667, 0.268331, 0.266667},
  {0.259752, 0.259752, 0.259785, 0.259741, 0.259751, 0.259764}}

TEg2g0 = {{0.318057, 0.405000, 0.540398, 0.720727, 0.945740, 1.216530}
   {0.234662, 0.330848, 0.467022, 0.639935, 0.848433, 1.098372},
  {0.109708, 0.0069634, -0.015400, -0.051312, -0.272904, -0.258691},
  {0.100111, 0.057204, 0.001593, -0.060967, -0.139916, -0.226860}}

TEg3g0 = {{0.000039, 0.000049, 0.000052, .000079, 0.000117, 0.000117},
  {0.000033, 0.000041, 0.000065, 0.000090, 0.000119, 0.000132},
  {0.000005, 0.000001, 0.000007, -0.000007, -0.000010, -0.000025},
  {0.000006, 0.000008, 0.000001, -0.000008, -0.000006, -0.000031}}

f[n_, s_, d_, ksi_] = 
 3*10^8*TEg0[[n, s]]/(Pi*d*ksi)*(1 + TEg1g0[[n, s]]*(1/ksi^2)^2 + 
    TEg2g0[[n, s]]*(1/ksi^2)^3 + TEg3g0[[n, s]]*(1/ksi^2)^4)

For[n = 1; s = 1, i < 5, i++, s++, s < 7, f[n_, s_, 1, 1000; Print[f]]
$\endgroup$

1 Answer 1

2
$\begingroup$

I'm not certain I've understood your question. However, if you intend to use the data (which I've cleaned up for you)

TEg0 = {{4.493410, 7.725252, 10.904120, 14.066190, 17.220750, 20.371300}, {5.763460, 9.095012, 12.322940, 15.5146000, 18.689040, 21.853870}, {6.987932, 10.417120, 13.698020, 16.923620, 20.121810, 23.304250}, {8.182562, 11.704910, 15.039660, 18.301260, 21.525420, 24.727570}};
TEg1g0 = {{0.400000, 0.400000, 0.400000, 0.400000, 0.400000, 0.400000},{0.285714, 0.285714, 0.285714, 0.285729, 0.285716, 0.285729}, {0.266667, 0.266667, 0.266667, 0.266667, 0.268331, 0.266667}, {0.259752, 0.259752, 0.259785, 0.259741, 0.259751, 0.259764}};
TEg2g0 = {{0.318057, 0.405000, 0.540398, 0.720727, 0.945740, 1.216530}, {0.234662, 0.330848, 0.467022, 0.639935, 0.848433, 1.098372}, {0.109708, 0.0069634, -0.015400, -0.051312, -0.272904, -0.258691}, {0.100111, 0.057204, 0.001593, -0.060967, -0.139916, -0.226860}};
TEg3g0 = {{0.000039, 0.000049, 0.000052, .000079, 0.000117, 0.000117}, {0.000033, 0.000041, 0.000065, 0.000090, 0.000119, 0.000132}, {0.000005, 0.000001,     0.000007, -0.000007, -0.000010, -0.000025}, {0.000006, 0.000008, 0.000001, -0.000008, -0.000006, -0.000031}};

And you construct the following Function to evaluate the various permutations

f[n_, s_, d_, ksi_] := 3*10^8*TEg0[[n, s]]/(\[Pi] d ksi) (1 + TEg1g0[[n, s]] (1/ksi^2)^2 + TEg2g0[[n, s]] (1/ksi^2)^3 + TEg3g0[[n, s]] (1/ksi^2)^4)

The you can use the Table command as follows

Table[f[n, s, 1, 1000], {n, 1, 4}, {s, 1, 6}]

to get

{{429089., 737707., 1.04127*10^6, 1.34322*10^6, 1.64446*10^6, 1.94532*10^6}, 
{550370., 868510., 1.17675*10^6, 1.48154*10^6, 1.78467*10^6, 2.08689*10^6}, 
{667298., 994762., 1.30806*10^6, 1.61609*10^6, 1.92149*10^6, 2.22539*10^6}, 
{781377., 1.11774*10^6, 1.43618*10^6, 1.74764*10^6, 2.05553*10^6, 2.36131*10^6}}
$\endgroup$
1
  • $\begingroup$ That's correct! Thank you so much for your help! $\endgroup$ Oct 10, 2016 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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