convert nans to 0
    7 views (last 30 days)
  
       Show older comments
    
Hi I have a large matrix and want to convert all nans to zeros. Any help?
0 Comments
Accepted Answer
  Oleg Komarov
      
      
 on 28 May 2012
        % Sample input with some NaNs
A = rand(10);
A(randi([1 100],[20,1])) = NaN;
% Detect and replace NaNs
idx    = isnan(A);
A(idx) = 0;
0 Comments
More Answers (0)
See Also
Categories
				Find more on Data Type Conversion 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!
