Replace NaN's in a table - I need some help

19 次查看(过去 30 天)
BN
BN 2019-12-19
回答: BN 2019-12-20
Hello all, I have a table namely T2,
it has 12 columns. in all of these columns I have some NaN values. I would like to replace NaNs in the 1 to 7 column. the problem is I want to replace these NaNs by non-NaN values in each column (the value in each row is stable).
for example ( for two columns):
NaN NaN NaN
NaN RAD NaN
Behezad RAD MORD
NaN NaN MORD
I want:
Behezad RAD MORD
Behezad RAD MORD
Behezad RAD MORD
Behezad RAD MORD
for each column. it is important that every column has it's own value. I don't want to have any change in column 8 to 12 NaNs
thank you, I wait for your kindly answers.
best regards
  7 个评论
BN
BN 2019-12-20
Thank you again. All values in each column are stable. I mean all up and down nan values are similar. These columns represent some features of one climate station for a time period (like the name of region and latitude and longitude of the station so all cells in 1 to 7 is similar. I want to replace nan with nearest none nan of each column in column 1 to 7. Thanks again ???
BN
BN 2019-12-20
I have 540 excel file like this for other weather stations. That's the reason I want to use the Matlab code.

请先登录,再进行评论。

回答(2 个)

Ridwan Alam
Ridwan Alam 2019-12-19
编辑:Ridwan Alam 2019-12-19
T2.col1(ismissing(T2.col1)) = "Behezad";
T2.col2(ismissing(T2.col2)) = "RAD";
T2.col3(ismissing(T2.col3)) = "MORD";
  2 个评论
BN
BN 2019-12-19
编辑:BN 2019-12-19
Dear Ridwan, thank you but, it's just a little example. my real data set is very larg and have very differents values (city names and latitude, longitude), I can't using this. I want to fill automaticly by non-nan values in each column. thank you
Capture.JPG
Ridwan Alam
Ridwan Alam 2019-12-19
Sure, Behzad. Please share what you've tried to automate this. And if there is any specific error or question, I would be glad to help. But, I am not willing to write your whole code for you.

请先登录,再进行评论。


BN
BN 2019-12-20

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by