filling missing value using linear interpolate in 2D

4 Ansichten (letzte 30 Tage)
chantel
chantel am 17 Okt. 2023
Bearbeitet: Torsten am 17 Okt. 2023
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 Kommentare
chantel
chantel am 17 Okt. 2023
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 am 17 Okt. 2023
Bearbeitet: Torsten am 17 Okt. 2023
Maybe you mean "fillmissing2" ?
But I wouldn't fill, but delete row 18 since the temperature measured is definitly a measuring error.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 17 Okt. 2023
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.
.

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by