Technical discussion about Matlab and issues related to Digital Signal Processing.
Hello, I just joined the forum since I have a problem by doing my term
paper concerning risk management. In a matrix "data" containing the
information of the financial data of thousands of companies in the
past 20 years, some elements are marked with "NaN" since the
corresponding information is not available. I need to delete those
rows which contain at least one "NaN" element so that I can run a
logit regression with the rest of the complete information. I tried as
follows:
for i = 1: length(data)
for j = 1: cols(data)
if data(i,j)==NaN
data(i,:)= []
......
(I omit some other codes that are irrelevant to this issue)
but seems that Matlab can not tell if the element in the matrix
contains "NaN" because after running the above codes the matrix
remains unchanged.
Could anyone please give me some suggestions? Thank you very much!
Hallo Jerome, Thank you very much indeed for your help! I didn't even expect that I could get a reply! At least not so soon. I tried your solution and it worked. Terse, and effective. I really appreciated your help. Best regards, Frank -----Ursprüngliche Nachricht----- Von: Dut [mailto:d...@yahoo.fr] Gesendet: Montag, 12. Mai 2008 14:57 An: lost_the_loving_feeling Cc: m...@yahoogroups.com Betreff: Re: [matlab] not-a-number (NaN) in Matlab Hi, try this : M = rand(8,3); M(M<0.3)=nan idx = isnan(M); idx = any(idx,2); M(idx,:) = [] Jerome Briot (Dut)