help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: index precision issues


From: Hall, Benjamin
Subject: RE: index precision issues
Date: Tue, 26 Apr 2005 14:29:27 -0400

How about using round to force octave to recognize your step size as an
integer, e.g.:

>>> lsnapshots = ps (:, 1:round(model.dts / model.dt):__end__)



-----Original Message-----
From: Joan Picanyol i Puig [mailto:address@hidden
Sent: Tuesday, April 26, 2005 2:15 PM
To: address@hidden
Subject: index precision issues


Hi,

I'm having issues using oversampling for some simulations. In short, I
have two different sample intervals:

model.dt=25*10^-9
model.dts=25*10^-5

I generate drop.t (which is my time variable) with model.dt intervals,
and, I later generate drop.ts, which is the time vector for spatial
processing:

drop.t = 0:model.dt:2 * model.r / model.v - model.dt;
drop.ts = drop.t(1):model.dts:drop.t(end);

So drop.ts has a subset of drop.t.

So far so good, the problem is when I'm trying to index vectors using
the ratio between model.dts and model.dt (my oversampling factor). I
believe my problem comes from some weird precision issue, since these
two statements have different results:

mod(25*10^-5/(25*10^-9), 1)
mod(25*10^-7/(25*10^-9), 1)

I used this as an integer test to ensure valid model.dts/model.dt
ratios, but it doesn't work as I thought.  When I try to use selected
samples from my long vector I get:

error: expecting integer index, found 1001.000000
error: in /usr/home/joan/wd/simulacions--mainline--0.6--current/rx_signal.m
near line 33, column 20:

>>> lsnapshots = ps (:, 1:model.dts / model.dt:__end__)


keyboard: stopped in
/usr/home/joan/wd/simulacions--mainline--0.6--current/one_drop.m at line 33
debug> disp(size(ps))
        3  1000000
debug> disp(model.dts/model.dt)
1000.0

What really has me wondering is why some combinations of model.dts and
model.dt
work and some not. Are there any other approaches to doing this? How do I
convert to an integer (I'm trying to remain Matlab compatible, and thus
avoid
isind)

tks
-- 
pica



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]