Need help with Matlab - I get an error
1 view (last 30 days)
Show older comments
'A Function that takes a number and return it with the desired number of decimal places';
for i = 0; i < DECIMAL_PLACES;
value = round((rawData(r,c)*100)/(100));
end
1 Comment
Walter Roberson
on 29 Sep 2016
This is not actually possible with binary floating point; decimal numbers are infinite repeating binary expansions, the same way that 1/7th is an infinite repeating expansion in decimal.
Answers (2)
Jan
on 29 Sep 2016
You forgot to mention the error message.
The function definition is missing (the line starting with "function"). Perhaps "DECIMAL_PLACES" is undefined.
You run a loop over "i" but use the potentially undefined indices r and c inside the loop.
The round() is misplaced. It should be applied to "rawData*100" only, not to "rawData*100/100" of course.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices 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!