質問

I'm running some simulations with Mathematica with NDSolve, and I need to introduce the effect of temperature. I define a table of random numbers and then make a function out of it, this way:

 randomtablex = 
      Table[RandomVariate[NormalDistribution[]], {i, 1, 
        IntegerPart[3 tspacer/deltats] + 1}];
    randomtabley = 
      Table[RandomVariate[NormalDistribution[]], {i, 1, 
        IntegerPart[3 tspacer/deltats] + 1}];
    randomtablez = 
      Table[RandomVariate[NormalDistribution[]], {i, 1, 
        IntegerPart[3 tspacer/deltats] + 1}];
    Bterp[t_] := 
      {randomtablex[[IntegerPart[t/deltats] + 1]], 
        randomtabley[[IntegerPart[t/deltats] + 1]], 
        randomtablez[[IntegerPart[t/deltats] + 1]]};

Where 3tspacer is the time of integration and deltats is the time when the thermal field changes. The simulation runs fine and the results are correct, but everytime i get this error message:

Part::pspec: "Part specification 1+IntegerPart[1000000000000 t] is neither an integer nor a list of integers."

As i said its not really a problem, but it bugs me that it keeps appearing... Is there any way to know where it came from, or should i just turn it off?

Thank you in advance

役に立ちましたか?

解決

this will happen if you access Bterp[] with a symbolic argument t

Try this:

ClearAll[Bterp]
Bterp[t_?NumericQ] := ....

http://support.wolfram.com/kb/3820

Aside, IntegerPart[x]+1 is the same as Ceiling[x] (assuming x>0...)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top