replace NaN values with numericl values
379 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
i have a NaN values in the matrix those i can not importing a numerical values in it the undefined variable error is appear
the question is what should i do to import the numerical matrix into NaN matrix ?
Thanks in advance.
4 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 4 月 3 日
If you want to replace the nan values by 0 for example
A(isnan(A))=0
5 件のコメント
その他の回答 (2 件)
BAPPA MUKHERJEE
2019 年 12 月 6 日
Hi
How can I replace some values with NAN form a time sries.
0 件のコメント
carolina franco
2020 年 1 月 28 日
Hi,
Another simple way to understand what's going on .
For me, it works well in R2014a. You only need to enter the matrix with NaN values without specifying the columns where NaN values are.
Here NaN values are replaced by 0s but you can easily modify it in the 8th line of this code:
%Input
m_data=C{1,1}; % Matrix with NaN values
%Code
s1=size(m_data,1);
for i= 1: s1
msubs=m_data(i,1:end); % Save existing data in ith row of m_data
msubs=msubs(isnan(m_data(i,1:end))==0); %Substitute matrix/ taking only non-NaN values
m_data(i,1:end)=0; %Erase all existing values in ith row of m_data and REPLACE by 0s
m_data(i,1:size(msubs,2))=msubs; %Substitute values without NaN
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!