Tag Info

Hot answers tagged

8

In a "natural" image, you'd look at each edge pixel in, use some approximation (e.g. 2nd order polynomial) of the gradients above/below that pixel and calculate the sub-pixel position of the steepest gradient. But in your case, all EdgeDetect gets to work on is a binary image, and any the potential anti aliasing sub-pixel information is lost. So the best ...


6

Sometimes, a linear interpolation is sufficient and setting InterpolationOrder->1 can avoid over/under-shoots in the interpolated function. EDIT You can also use an auxiliary function made to keep the values non-negative while keeping a sort of smoothness: ClearAll[keepPositive]; Attributes[keepPositive] = {Listable}; keepPositive[x_] := ...


6

A short one: fn = Interpolation /@ Transpose@pts; ParametricPlot[Through@fn@x, {x, 1, Length@pts}] The following is another way. I think it's poorly documented (or not at all).Note that the function interpoltion returns a list from a scalar. fn = Interpolation[Transpose[{Range@Length@pts, pts}]]; ParametricPlot[fn@x, {x, 1, Length@pts}]


5

fx = Interpolation[pts[[All, 1]]]; fy = Interpolation[pts[[All, 2]]]; ParametricPlot[{fx[t], fy[t]}, {t, 1, Length[pts]}, AspectRatio -> 1/GoldenRatio] plot


3

My answer here is effectively an answer to this question as well; I'll leave to other people the decision of whether to close this as a dupe. Details on the proceedings can be read in my other answer. Here, I will merely present results: pts = SortBy[{{0., 0.}, {3., 4.}, {-1., 5.}, {-4., 0.}, {-5., -3.}, {-10., -11.}, {-11., -12.}}, First]; m ...


3

I can think of two approaches if all you have are function values, (1) fitting a smooth a model to your data, and (2) estimating the derivatives using finite differences and incorporating those estimates in an interpolating function. The first requires some insight into potential target models, about which none has been given. So I'll show the second ...


3

As the Norm is positive, you don't really need the constraint to determine one minimum for p and t: nm = NMinimize[{ (Norm[{xm[t][p], ym[t][p]} - {xsc[t][p], ysc[t][p]}] - 10^7)^2 /. Soln, TOF - 10 (86400) < t < TOF + 10 (86400) && 0.8 < p < 1}, {t, p}, Method -> "NelderMead"] (* {0.000155262, ...


3

I think it is best to approach these kinds of problems with pure functions, which minimizes nasty surprises from variable scoping issues. Let's see how well this idea works out when applied to your problem. Generate test data. With[{u = Range[-180., 180., 6.] Degree}, data = With[{x = #[[1]], y = #[[2]]}, {x, y, Sin[x] Cos[ y]}] & /@ ...


3

In the absence of definitions for several functions and constants, I chose v[t] = 1; vdot[t] = 1; todaya = .8; EQfraca = .5; ωa = 1; ρ0 = 1; mina = 0.9; maxa = 1.3; NDSolve then yields two InterpolatingFunctions (* {{a -> InterpolatingFunction[{{0.5, 0.8}}, <>]}, {a -> InterpolatingFunction[{{0.5, 0.8}}, <>]}} *) which in turn ...


2

If you have your data in an array 'data' you can simply run ListInterpolation on each entry of the array via Map or /@ lip = ListInterpolation /@ data or if you have to supply additional arguments lip = ListInterpolation[#, whatever option or argument] & /@ data


2

What you want to do can be accomplished pretty simply by rewriting your expression as a function. eqn[p_] := Sqrt[0.04 + u + u^2] == 2.0 + 3.0 p uPts = Table[Flatten[{p, NSolve[eqn[p], u][[All, 1, 2]]}], {p, 0, 99}]; u1 = Interpolation[uPts[[All, {1, 2}]]]; u2 = Interpolation[uPts[[All, {1, 3}]]] Plot @@ {Through[{u1, u2}[t]], Flatten[{t, u1["Domain"]}], ...


2

As noted by the OP, adding the constraint, Norm[{xm[t][p], ym[t][p]} - {xsc[t][p], ysc[t][p]}] > 10000000 /. Soln triggers error messages, probably because p typically must be given a numerical value before t is given one in expressions such as xm[t][p]. See the documentation for ParametricFunction. This can be accomplished by defining ...


1

To illustrate the point made in my recent comment, gpap is correct that f = Interpolation[Table[{x, Sin@x}, {x, 0, 2 Pi, 2 Pi/100}], InterpolationOrder -> 2]; g[x_] := f''[x]/f[x]; Plot[{f[x], g[x]}, {x, 0, 2 Pi}] does not give a well behaved expression for g[x]. However, using f = Interpolation[Table[{x, Sin@x}, {x, 0, 2 Pi, 2 Pi/100}], ...


1

The interpolateCurve function gives the interpolation of curves. Options[interpolateCurve] = Join[Options[ParametricPlot3D], Options[Interpolation]]; interpolateCurve[pts : {{_, _} ..}, opts : OptionsPattern[]] := Module[{order, x, y, s, func1, func2}, order = OptionValue[InterpolationOrder]; x = pts[[All, 1]]; y = pts[[All, 2]]; ...



Only top voted, non community-wiki answers of a minimum length are eligible