filling missing value using linear interpolate in 2D

조회 수: 7 (최근 30일)
chantel
chantel 2023년 10월 17일
편집: Torsten 2023년 10월 17일
From the attached file, i used FUni=fillingmissing2(filename,''linear'') to fill the missing numbers from my data, is this the correct code but i am not quite sure about it, i just need confirmation before i go further
  댓글 수: 3
chantel
chantel 2023년 10월 17일
Initially i had an empty space in my excel sheet, then after running that code on the imported file, the empty value was filled so i am confused by your response
Torsten
Torsten 2023년 10월 17일
편집: Torsten 2023년 10월 17일
Maybe you mean "fillmissing2" ?
But I wouldn't fill, but delete row 18 since the temperature measured is definitly a measuring error.

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

답변 (1개)

Star Strider
Star Strider 2023년 10월 17일
This works —
T1 = readtable('GreenhouseData.xlsx', 'VariableNamingRule','preserve')
T1 = 24×3 table
Time Temperature (°C) Humidity (%) ________ ________________ ____________ 0 {'22.5'} {'45.2'} 0.041667 {'23.0'} {'44.7'} 0.083333 {'23.5'} {'44.2'} 0.125 {'24.0'} {'43.9'} 0.16667 {'23.8'} {'43.5'} 0.20833 {'24.2'} {'43.1'} 0.25 {'24.5'} {'43.1'} 0.29167 {'57.9'} {'44.1'} 0.33333 {'25.0'} {'45.2'} 0.375 {'25.2'} {'49.4'} 0.41667 {'25.5'} {'58.1'} 0.45833 {'25.8'} {'63.3'} 0.5 {'26.0'} {'69.3'} 0.54167 {'26.2'} {'77.7'} 0.58333 {'26.5'} {'85.2'} 0.625 {'26.8'} {'88.3'}
VN = T1.Properties.VariableNames;
T1(:,[2 3]) = fillmissing(T1(:,[2 3]),'constant','NaN');
T2 = fillmissing(varfun(@str2double,T1, 'InputVariables',[2 3]), 'linear');
T2 = addvars(T2, T1{:,1}, 'Before',1);
T2.Properties.VariableNames = VN
T2 = 24×3 table
Time Temperature (°C) Humidity (%) ________ ________________ ____________ 0 22.5 45.2 0.041667 23 44.7 0.083333 23.5 44.2 0.125 24 43.9 0.16667 23.8 43.5 0.20833 24.2 43.1 0.25 24.5 43.1 0.29167 57.9 44.1 0.33333 25 45.2 0.375 25.2 49.4 0.41667 25.5 58.1 0.45833 25.8 63.3 0.5 26 69.3 0.54167 26.2 77.7 0.58333 26.5 85.2 0.625 26.8 88.3
figure
plot(T2.Time, T2{:,[2 3]})
grid
xlabel(VN{1})
ylabel('Value')
legend(VN{[2 3]}, 'Location','NW')
It should be easier to use varfun for these conversions. It should not require creating a separate table.
.

카테고리

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

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by