フィルターのクリア

How do i find repeating sample with different value in data and replace the value with its average?

2 ビュー (過去 30 日間)
In the file "air.mat" , contains a matrix named data, in which the first column is the energy (MeV) and the second column
represents the connected mass attenuation coefficient.
There is two same energy values with different mass attenuation coefficient. How do i find those same energy values and replace it with the average of the mass attenuation coefficient of both energies.
I tried using unique() but it doesnt give the output that i need i need
x=load("air.mat");
c=unique(x.data(:,1))
c = 37×1
0.0010 0.0015 0.0020 0.0030 0.0032 0.0040 0.0050 0.0060 0.0080 0.0100
This is just removing the repeating energy value from data.

採用された回答

Simon Chan
Simon Chan 2022 年 2 月 12 日
Try this:
T = table(data(:,1),data(:,2),'VariableNames',{'Energy','mass_attentuation_coefficient'});
G = groupsummary(T,"Energy","mean");

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by