Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Results tagged with interpolation
Search options not deleted
user 6358
Questions on the interpolation functions in Mathematica (InterpolatingFunction[], Interpolation[], ListInterpolation[], FunctionInterpolation[], InterpolatingPolynomial[], etc.)
4
votes
How to restrict InterpolatingFunction to a smaller domain?
Maybe the following meets your desiderata:
if2[x_ /; 1 <= x <= 2] = if[x];
if2[0.9]
(* if2[0.9] *)
if2[1.1]
(* 1.21 *)
5
votes
Accepted
Interpolation not working
Show[
ListPlot[data, PlotStyle -> Black],
Plot[Evaluate@Interpolation[data][x], {x, 0, 120}, PlotRange -> All]
]
If those wiggles bother you, use linear interpolation instead:
Show[
ListPlot[data, … try this approach to regularised Interpolation. …
4
votes
Taking Part of an InterpolatingFunction
Most (if not all) of my actual InterpolatingFunctions use InterpolationMethod Hermite, so I tried tweaking @Mr.Wizard's and @MichaelE2's answers to deal with them, while still addressing discontinuous …
10
votes
4
answers
673
views
Taking Part of an InterpolatingFunction
NumericQ}] :=
Interpolation[Join[
{{xmin, if[xmin]}},
Select[Transpose[{if["Coordinates"][[1]], if["ValuesOnGrid"]}], xmin < #[[1]] < xmax &],
{{xmax, if[xmax]}}
]];
It generally works OK, but … Simply deleting one of the duplicate points is no good because it completely messes up the interpolation.
This very issue was explored in depth in this answer by Michael E2. …
3
votes
Taking Part of an InterpolatingFunction
With help from a few clues in @MichaelE2's comments, I think I've solved Problem 2 (discontinuous InterpolatingFunctions). First, define discontInterpolation from this answer. Then define
discontIn …
8
votes
3
answers
268
views
Make an InterpolatingFunction periodic
Interpolation can make an InterpolatingFunction periodic with the option PeriodicInterpolation. Can we make an InterpolatingFunction that already exists periodic, perhaps the output of NDSolve? …
5
votes
Make an InterpolatingFunction periodic
Yes, if we're willing to risk modifying the internals of the InterpolatingFunction. Using info from this answer from MichaelE2 and some guesswork, it looks like we need to change three things in the …
3
votes
Accepted
Returning an InterpolatingFunction
options *)
interpolationopts,interpolationpoints,
(* other variables *)
xmin,xmax,ifs,grid,tmp},
(* handle options *)
interpolationopts=FilterRules[Flatten[{opts,Options[Reinterpolation]}],Options[Interpolation … If[interpolationpoints===Automatic,
grid=Union[Flatten[Through[ifs["Grid"]],1]],
{xmin,xmax}=ifs[[1,1,1]];
grid=Table[x,{x,xmin,xmax,(xmax-xmin)/(interpolationpoints-1)}];
];
Quiet[
tmp=Interpolation …
3
votes
How to tell NDSolve to suppress creation of interpolation function on successful exit?
Just replace the list of variables being solved for with an empty list. E.g.
NDSolve[{n'[t] == n[t] (1 - n[t]), n[0] == 0.1,
WhenEvent[n[t] == 0.5, Print[t]]}, n, {t, 0, 10}]
(* 2.19722 *)
NDSol …
3
votes
0
answers
38
views
ExtrapolationHandler near miss
The following works as expected:
if = Interpolation[Table[{x, Sin[x]}, {x, 10^-3, 2 \[Pi], 0.1}],
"ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}]
(* InterpolatingFunction[<0.001 … , 6.2>] *)
if[0]
(* Indeterminate *)
However if the extrapolated point is just outside the range, ExtrapolationHandler lets me down:
if = Interpolation[Table[{x, Sin[x]}, {x, 10^-6, 2 \[Pi], 0.1}], …
6
votes
3
answers
656
views
Plot 1D slice of 2D InterpolatingFunction
I'm numerically solving a PDE (time+1D space) with NDSolve and want to plot some spatial profiles. Plot works, but is very slow compared to ListPlot. Here's an example (Fisher-KPP equation):
l = 10 …
5
votes
Accepted
NDSolve with an interpolating function in Piecewise
Encapsulating the right-hand side in a NumericQ-protected function and setting the MaxStepSize to 1 seems to work for me:
df[t_?NumericQ] := Piecewise[{{7, datafunc[t] > 0.}, {-5, datafunc[t] <= 0.}} …
3
votes
Accepted
Plot 1D slice of 2D InterpolatingFunction
NumericQ] := Module[{if, grid},
if = InterpolatingFunction[stuff];
grid = (InterpolatingFunction[stuff])["Grid"];
Return[(Interpolation@Transpose@{
grid[[All, 1, {1}]], (* extract x-grid *) … NumericQ, var_Symbol] := Module[{if, grid},
if = InterpolatingFunction[stuff];
grid = (InterpolatingFunction[stuff])["Grid"];
Return[(Interpolation@Transpose@{
grid[[1, All, {2}]], (* extract …
9
votes
4
answers
2k
views
Transform an InterpolatingFunction
sol5IFN = Interpolation[Transpose[{ln["Grid"], Exp[ln["ValuesOnGrid"]]} /.First@sol4]];
Plot[sol5IFN[t], {t, 0, 100}]
Looking at the underlying grid makes it obvious what the problem is:
ListPlot[ … [sol6[t], {t, 0, 100}]
UPDATE 2: Higher InterpolationOrder
sol5IFN = Interpolation[Transpose[{ln["Grid"], Exp[ln["ValuesOnGrid"]]} /. …