Floating point problems in C and Matlab

Hey there, I have floating point problems in my matlab-mex file where I get values at the magnitude 10^(-12) to 10^(-13)... Is there an 'dirty' way to solve them to at least set those values to zero after the computation if they are so small? Thanks!

Answers


If it's an array, you could do something like:

small_inds = find(abs(array) < 10^-12);
array(small_inds) = zeros(length(small_inds),1);

(edited to add abs() for clarity—thanks nimrodm)


Need Your Help

Extending Perl is breaking dynamic loading

perl hp-ux u2 perl-xs

I'm trying to compile an XS into perl [ed(ikegami): which is to say he's using ::MakeMaker's make perl to create a perl with a C vendor library statically linked in ] but when I do, the new version...

Prevent HTML encoding in auto-generated GridView columns

asp.net gridview

I have a GridView bound to a DataTable that I construct. Most columns in the table contain the raw HTML for a hypelinklink, and I would like that HTML to render as a link in the browser, but the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.