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 Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by