replace NaN values with numericl values

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
Azzi Abdelmalek 2014년 4월 3일
Do what?
what should i do to import the numerical matrix into NaN matrix ?
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 3일
How your text file looks like?
lina
lina 2014년 4월 3일
nc files those for marine physics not all of variables are apear

댓글을 달려면 로그인하십시오.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 3일

15 개 추천

If you want to replace the nan values by 0 for example
A(isnan(A))=0

댓글 수: 5

lina
lina 2014년 4월 3일
it works with me but i still have undefined variables
Abdul Haleem  Butt
Abdul Haleem Butt 2015년 11월 16일
what to do if we want to replace nan values by some numeric values i have patient ids like this HC01MI and i want to give some random numeric values to these ids
Javaid Iqbal
Javaid Iqbal 2018년 5월 15일
Thanks a lot sir for helping
madhusmita sahu
madhusmita sahu 2020년 5월 4일
thank you so much sir
charles Chamcha
charles Chamcha 2023년 3월 18일
thanks

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

BAPPA MUKHERJEE
BAPPA MUKHERJEE 2019년 12월 6일

0 개 추천

Hi
How can I replace some values with NAN form a time sries.
carolina franco
carolina franco 2020년 1월 28일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

질문:

2014년 4월 3일

댓글:

2023년 3월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by