|
From: | Ozzy Lash |
Subject: | Re: Calculation issue with octave (data unexpectedly go to zero at some point) |
Date: | Thu, 27 Feb 2014 17:41:50 -0600 |
Look, this is hardly a minimalistic code... Indeed, you can isolate
the problem quit eeasily.
If you just print the value of n inside your function
temporalEvolution (I called main(10)), you will see that indeed n
reaches only up to 27 instead of 51.
This says the mod(t, 0.2/Gamma) is zero only 27 times. So the question
to ask is whether the vector "y" in the following code is the same in
matlab and in octave
Gamma = 1.62e7;
duration = 10/Gamma;
dt = 0.0025/Gamma;
t = 0:dt:duration;
y = mod (t, 0.2/Gamma);
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
I think the assumption here is that since 0.2/Gamma is exactly 80 times larger than dt, that every 80th time through n will be incremented. So since the duration is 4000 time dt (leading to 4001 samples total) it expects the the modulus will be 0 51 times. It isn't surprising that mod has some issue with this, since comparing to 0 on floating point numbers can be tricky at best. I tried useing mod(t.0.2/Gamma) < eps, and 2*eps, and they gave more increments, but not the full 51. I'm surprised that Matlab does as well as it does with this.
Bill
[Prev in Thread] | Current Thread | [Next in Thread] |