trailing 01s and 9s
Show older comments
Hi guys,
I'm having rounding issues in my answers:
freq_in = 1.499;
h = 0:1:H-1;
f_harm = (h+1)*freq_in
f_harm =
1.499000000000000 2.998000000000000 4.497000000000000 5.996000000000000 7.495000000000001
f_gdf = mod(f_harm,40/8);
f_gdf =
1.499000000000000 2.998000000000000 4.497000000000000 0.996000000000000 2.495000000000001
a = (2*mod((1:I)',2)-1) * f_gdf;
f_gd = repmat((Fs*floor((g+1)/2)/I)',1,H) + a
f_gd =
1.499000000000000 2.998000000000000 4.497000000000000 0.996000000000000 2.495000000000001
3.501000000000000 2.002000000000000 0.503000000000000 4.004000000000000 2.504999999999999
6.499000000000001 7.998000000000000 9.497000000000000 5.996000000000000 7.495000000000001
8.500999999999999 7.002000000000000 5.503000000000000 9.004000000000000 7.504999999999999
11.499000000000001 12.998000000000001 14.497000000000000 10.996000000000000 12.495000000000001
13.500999999999999 12.001999999999999 10.503000000000000 14.004000000000000 12.504999999999999
16.498999999999999 17.998000000000001 19.497000000000000 15.996000000000000 17.495000000000001
18.501000000000001 17.001999999999999 15.503000000000000 19.003999999999998 17.504999999999999
The trailing 9s are causing problems in my script later on when I use the floor function. Is there a method for rounding it to whatever it would take to flip the 9s into 0s? Thanks.
Accepted Answer
More Answers (1)
Walter Roberson
on 20 Sep 2011
0 votes
Not really, no. I suggest you read http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!