1
$\begingroup$

This question is in continuation of my earlier query, https://mathematica.stackexchange.com/q/43568/3066. I am able to store the output of my function in a table, however the table consists of various brackets and variable headings which I do not require. A clean table with only values in two columns will help me to further evaluate the table.

I have many such codes, resulting in about 15 tables each containing 600 rows of data. A easy way to have the table in required format as above will help me avoid lot of formatting.

Further the code as below also gives 2 values for a single input value. I will like both the values to be given in two separate rows.

The code is as given below. Request for help to solve this.

Remove["Global`*"]
Clear[A, r, v, u, p, γ , ug, Nx, Ny, Nz, EM]
x = 2 r Cos[v + u + γ] - r Cos [(2 v) + u + γ]
Nxu = D[x, u]
Nxv = D[x, v]
Nx = Nxu Nxv

y = 2 r Sin[v + u + γ] - r  Sin[(2 v) + u + γ]
Nyu = D[y, u]
Nyv = D[y, v]
Ny = Nyu Nyv

z = p u
Nzu = D[z, u]
Nzv = D[z, v]
Nz = Nzu Nzv

re = 27.5
r = 16.5
g = ArcCos[((5 r^2) - (re^2))/(4 r^2)]
p = 108/(2 π)
γ = 45 ° 2 Pi / 360
A = 50 + r
γc = 46 ° 2 Pi / 360

EM [u_, v_] = Simplify[(A - x + p Cot[γc]) Nz + (A Cot[γc]) Ny + z Nx ]
ug[thet_] := With[{u = thet}, NSolve[EM[u, v] == 0 && 0 <= v <= g, v, Reals]]

myTable = Map[{#, ug[#]} &, Range[0, 2 Pi, 0.1]]

Export["coordinatesM13.xls", myTable]

The output for the table is currently as below:

{{0., {}}, 
 {0.1, {}}, 
 {0.2, {}}, 
 {0.3, {}}, 
 {0.4, {}}, 
 {0.5, {}}, 
 {0.6, {}}, 
 {0.7, {}}, 
 {0.8, {}}, 
 {0.9, {}}, 
 {1., {}}, 
 {1.1, {}}, 
 {1.2, {{v -> 0.877726}}}, 
 {1.3, {{v -> 0.757594}}}, 
 {1.4, {{v -> 0.616049}}},
 {1.5, {{v -> 1.48929*10^-17}, {v -> 0.418666}}}, 
 {1.6, {}}, 
 {1.7, {{v -> 4.32695*10^-17}, {v -> 0.94549}}}, 
 {1.8, {{v -> 9.4028*10^-17}, {v -> 0.879002}}}, 
 {1.9, {{v -> 1.4318*10^-16}, {v -> 0.812557}}}, 
 {2., {{v -> 1.94556*10^-16}, {v -> 0.746152}}}, 
 {2.1, {{v -> 2.50387*10^-16}, {v -> 0.679788}}}, 
 {2.2, {{v -> 3.13018*10^-16}, {v -> 0.613464}}}, 
 {2.3, {{v -> 3.85566*10^-16}, {v -> 0.54718}}}, 
 {2.4, {{v -> 4.72647*10^-16}, {v -> 0.480935}}}, 
 {2.5, {{v -> 5.8166*10^-16}, {v -> 0.414731}}}, 
 {2.6, {{v -> 7.25488*10^-16}, {v -> 0.348566}}}, 
 {2.7, {{v -> 9.28936*10^-16}, {v -> 0.282443}}}, 
 {2.8, {{v -> 1.24694*10^-15}, {v -> 0.216362}}}, 
 {2.9, {{v -> 1.83073*10^-15}, {v -> 0.150324}}}, 
 {3., {{v -> 3.30427*10^-15}, {v -> 0.0843294}}}, 
 {3.1, {{v -> 1.52413*10^-14}, {v -> 0.0183812}}}, 
 {3.2, {}}, 
 {3.3, {}}, 
 {3.4, {}}, 
 {3.5, {}}, 
 {3.6, {}}, 
 {3.7, {}}, 
 {3.8, {}}, 
 {3.9, {}}, 
 {4., {}}, 
 {4.1, {}}, 
 {4.2, {}}, 
 {4.3, {{v -> 0.944253}}}, 
 {4.4, {{v -> 0.828585}}}, 
 {4.5, {{v -> 0.697065}}}, 
 {4.6, {{v -> 2.7593*10^-17}, {v -> 0.531873}}}, 
 {4.7, {{v -> 0.0583604}, {v -> 0.125963}}}, 
 {4.8, {{v -> 0.960336}}}, 
 {4.9, {{v -> 5.11674*10^-17}, {v -> 0.894928}}}, 
 {5., {{v -> 1.088*10^-16}, {v -> 0.829509}}}, 
 {5.1, {{v -> 1.63611*10^-16}, {v -> 0.764084}}}, 
 {5.2, {{v -> 2.20467*10^-16}, {v -> 0.698659}}}, 
 {5.3, {{v -> 2.82376*10^-16}, {v -> 0.633237}}}, 
 {5.4, {{v -> 3.5243*10^-16}, {v -> 0.567823}}}, 
 {5.5, {{v -> 4.34721*10^-16}, {v -> 0.502421}}}, 
 {5.6, {{v -> 5.35437*10^-16}, {v -> 0.437036}}}, 
 {5.7, {{v -> 6.64873*10^-16}, {v -> 0.37167}}}, 
 {5.8, {{v -> 8.41904*10^-16}, {v -> 0.306328}}}, 
 {5.9, {{v -> 1.10567*10^-15}, {v -> 0.241014}}}, 
 {6., {{v -> 1.5532*10^-15}, {v -> 0.175731}}}, 
 {6.1, {{v -> 2.51035*10^-15}, {v -> 0.110485}}}, 
 {6.2, {{v -> 6.17841*10^-15}, {v -> 0.0452779}}}}
$\endgroup$
4
  • $\begingroup$ Please format your question, have a look at the markdown help. $\endgroup$
    – Yves Klett
    Commented Mar 7, 2014 at 14:13
  • 4
    $\begingroup$ This is your third question. By now you should have noticed that we like to see properly formatted code on this site. Just dumping code and data into your question is not the way to attract answers. $\endgroup$
    – m_goldberg
    Commented Mar 7, 2014 at 14:14
  • $\begingroup$ Seems like a job for Part where you can extract whatever parts of your list you wish. $\endgroup$
    – bill s
    Commented Mar 7, 2014 at 15:27
  • $\begingroup$ In your current output, whenever you have two rules for v, the first rule is suspiciously close to zero. Do you really want all those different approximations to zero? Or should be chopped to zero? Or simply removed? You really need to show us how you want your final output to look. $\endgroup$
    – m_goldberg
    Commented Mar 7, 2014 at 15:43

1 Answer 1

3
$\begingroup$

Try this...

myTable = Map[{#, (v /. Last[ug[#]]) /. v->Indeterminate} &, Range[0, 2 Pi, 0.1]]
$\endgroup$
2
  • $\begingroup$ many thanks @Ymareth, I am able to get the required. Thanks for helping me save lot of formatting time $\endgroup$ Commented Mar 8, 2014 at 5:49
  • 2
    $\begingroup$ @kamalagrawal If the answer fits your needs you can accept it with a mark below the score. Please, take a tour $\endgroup$
    – Kuba
    Commented May 6, 2014 at 18:03

Your Answer

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

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