readtable excel decimal NaN

조회 수: 2 (최근 30일)
Johannes Deelstra
Johannes Deelstra 2020년 11월 5일
답변: Priysha LNU 2020년 11월 11일
I use readtable to get access to excel data
some cells in the excell file contain no data and instead have a decimal point,
how can I replace these cells with NaN
regards
Johannes
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 11월 5일
Can you show how these values are loaded in MATLAB?
Johannes Deelstra
Johannes Deelstra 2020년 11월 5일
I use TT=readtable('Skutavr_tapNBTemp94-19_dag.xlsx');
then the data are entered as
'01.05.1994' 0.450000000000000 '1.03' '0.04' '11' '0' '6.6' '1.6' '0.065' '18'
'02.05.1994' 0.360000000000000 '0.59' '0.028' '7' '0.1' '7.9' '0.9' '0.046' '12'
'03.05.1994' 0.310000000000000 '0.34' '0.022' '5' '0' '7.3' '0.5' '0.035' '9'
'04.05.1994' 0.300000000000000 '0.33' '0.021' '5' '0' '9.5' '0.5' '0.034' '9'
because tfhere is a series with no data indicated as
'11.01.1996' 0.110000000000000 '0.04' '0.002' '0' '2.998' '1.1' '0.1' '0.004' '1'
'12.01.1996' 0.160000000000000 '.' '.' '.' '1.996' '0.9' '.' '.' '.'
'13.01.1996' 0.130000000000000 '.' '.' '.' '6.3' '0.9' '.' '.' '.'
'14.01.1996' 0.710000000000000 '.' '.' '.' '3.7' '0.9' '.' '.' '.'
'15.01.1996' 0.590000000000000 '.' '.' '.' '0.1' '0.9' '.' '.' '.'
'16.01.1996' 0.400000000000000 '.' '.' '.' '0' '-0.8' '.' '.' '.'
regards
Johannes

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

답변 (1개)

Priysha LNU
Priysha LNU 2020년 11월 11일
Hi,
Try using the following code:
[m,n] = size(Data) %gives number of rows and columns in 'Data'
for i = 1:m
for j = 1:n
if strcmp(Data{i,j},'.') %check if cell content is "."
Data{i,j} = NaN %replace with NaN
end
end
end
DISCLAIMER: These are my own views and in no way depict those of MathWorks.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by