Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Trasform 'values' inside table in numeric values always inside a table

1 回表示 (過去 30 日間)
gcicceri
gcicceri 2020 年 7 月 14 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi guys,
I have a problem.
I get a dataset table in this format, with values between ' ' :
Date var_1 var_2 var_3 var_4 var_5 var_6
01-01-90 'NaN' 'NaN' 'NaN' 'NaN' 'NaN' 'NaN'
01-01-91 '-0.012' '0' '0.028' '0' '0.017' '-0.016'
01-01-92 '0' '0.020' '0.105' '0' '0.034' '0.048
01-01-93 '0.006' '0' '-0.051' '0' '0' '0'
01-01-94 '0.007' '0' '0.025' '0' '-0.008' '-0.048'
My goal is to compute mean, std, etc , and with this format is impossible to make these statistics.
how do I trasform these values into numerical values? Always in a table?
Thanks
  1 件のコメント
madhan ravi
madhan ravi 2020 年 7 月 14 日
Instead of pasting the output from a command window , will you in the future upload data as .mat file or a copy paste format so that it’s easier to answer??

回答 (2 件)

Matt J
Matt J 2020 年 7 月 14 日
編集済み: Matt J 2020 年 7 月 14 日
One way,
varfun(@(z) mean(str2double(z)) , yourTable(:,2:end))

madhan ravi
madhan ravi 2020 年 7 月 14 日
編集済み: madhan ravi 2020 年 7 月 14 日
The correct way:
T(:,2:end) = num2cell(cellfun(@str2double,T{:,2:end},'un',0)); % T your table
mean(cell2mat(T{:,2:end}),'omitnan')

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by