Tag Info

New answers tagged

3

I feel a bit foolish posting such a simple answer after the two complete examples above, but I think it bears pointing out that version 10 includes a function specifically for removing Missing values: DeleteMissing:


6

This uses some version 10 functions: Getting the data (takes time as I could have set this up better): dat = Table[{i, j, WeatherData[{j, i}, #] & /@ {"WindSpeed", "WindDirection"}}, {i, 113, 153, 4}, {j, -43, -11, 4}]; Processing: data = Cases[{{#1, #2}, -QuantityMagnitude[#3[[1]]] {1/Cos[#2 Degree], 1} Through[{Sin, ...


10

NB I think there's a problem with this code, please see this answer by ubpdqn for more information. I'll update these snippets when I get the chance. Yours is a question with many possible interpretations. I've chosen the interpretation that was most fun for me to play with, so... ang = 20; (* divide the world into chunks of this size *) pts = ...


3

It is almost always better to deal with these problems during import rather than afterward. Follow up Pickett's comment you could use something like this: string = "10.350,20,20.000,10.700,30,40.522"; ImportString[string, "CSV", NumberPoint -> ","] {{10350, 20, 20000, 10700, 30, 40522}} Except that in your application you would presumably use ...


1

You can deselect the integers. a = {10.350, 20, 20.000, 10.700, 30, 40.522}; IntegerQ /@ a {False, True, False, False, True, False} To multiply all elements of a except 2nd and 5th :- b = DeleteCases[a, _?IntegerQ] {10.35, 20., 10.7, 40.522} Times @@ b 89752.2


0

Here's a method that uses LeviCivita and defines the cross product in terms of its index notation expression: Cr[ms_, a_] := Map[Sum[ LeviCivitaTensor[3][[#, j, k]] ms[[j]] a[[k]], {j, Range[3]}, {k, Range[3]} ] &, Range[3]] /; 3 == Length[ms] == Length[a] In dimensions other than 3, the analogously defined cross product is not a ...


1

Much has already been said about this problem, but maybe this solution still might be helpful. First we define an auxiliary vector In[18]:= va = Array[a, 3] Out[18]= {a[1], a[2], a[3]} with which it is trivial to calculate the cross product: In[19]:= Cross[va, {1, 2, 3}] Out[19]= {3 a[2] - 2 a[3], -3 a[1] + a[3], 2 a[1] - a[2]} Now we replace the ...


2

I hope this is helpful (if I interpret your aim correctly): This is a little more challenging for your particular function. g[x_, y_] := {-5.4 E^(-2.25 ((-4 + x)^2 + (-2.5 + y)^2)) (-4 + x) - 6.4 E^(-4 ((-3.5 + x)^2 + (-1.5 + y)^2)) (-3.5 + x) - 8 E^(-4 ((-3 + x)^2 + (-3.5 + y)^2)) (-3 + x) - 9. E^(-9 ((-2.5 + x)^2 + (-1.5 + y)^2)) (-2.5 + x) - ...


4

Here is a version of curvature that uses Mathematica machinery not available to Wagner, who used V3. curvature[x_, y_, z_] := Module[{s, v, vMag, T}, Block[{$Assumptions = {{x, y, z} ∈ Reals}}, s = {x, y, z}; v = D[s, t]; vMag = Surd[v.v, 2]; T = v/vMag; Simplify[Norm[D[T, t]/vMag]]]] curvature[Cos[t], Sin[t], t] 1/2 ...


3

An alternative: $Assumptions = t \[Element] Reals; J[{x_, y_}] := {-y, x} Curvature[a_][t_] := a''[t].J[a'[t]]/Norm[J[a'[t]]]^3 // Simplify circle[a_][t_] := {a Cos[t], a Sin[t]} Curvature[circle[2]][t] ellipse[a_, b_][t_] := {a Cos[t], b Sin[t]} Curvature[ellipse[2, 3]][t] Curvature[ellipse[2, 3]][Pi] $Assumptions = True; (* Clear *)


6

Norm in general assumes complex arguments and uses Abs to provide for that: Norm[{x, y}] Sqrt[Abs[x]^2 + Abs[y]^2] For real elements, you can either add an assumption for Simplify or manually get rid of Abs beforehand: Simplify[Norm[{Cos[t], Sin[t]}], Element[t, Reals]] Simplify[Norm[{Cos[t], Sin[t]}] /. Abs -> Identity] 1 1 This now ...



Top 50 recent answers are included