MEAN OF A VARIABLE WITH RESPECT TO OTHER VARIABLES

2 ビュー (過去 30 日間)
SAPTORSHEE KANTO
SAPTORSHEE KANTO 2024 年 8 月 21 日
コメント済み: SAPTORSHEE KANTO 2024 年 8 月 22 日
I would like to find mean of the variable a25 other variable a6a7 and by year .
input int(year a6a7) long a25
2017 121 12000
2017 121 30000
2017 121 13000
2017 121 14000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 20000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 14000
2017 121 35000
2017 121 6000
2017 121 2000
2017 121 10000
2017 17 15000
2017 17 15000
2017 17 12000
2017 17 15000
2017 17 15000
2017 17 8000
2017 17 7000
2017 17 5000
2017 121 10000
2017 121 10000
2017 121 6000
2017 121 8000
2017 121 8000
2017 121 12000
2017 121 10000
2017 121 10000
2017 121 16000
2017 121 8000
2017 121 12000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 8000
2017 121 6000
2017 121 6000
2017 121 6000
2017 121 10000
2017 121 10000
2017 121 10000
2017 121 7000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 15000
2017 121 5000
2017 121 10000
2017 121 10000
2017 17 25000
2017 17 8000
2017 17 8000
2017 17 10000
2017 17 7000
2017 17 6000
2017 17 3500
2017 17 8000
2017 17 20000
2017 17 16000
2017 17 16000
2017 17 14000
2017 17 25000
2017 17 15000
2017 17 16000
2017 17 16000
2017 121 12000
2017 121 15000
2017 121 12000
2017 121 12000
2017 121 13000
2017 121 12000
2017 121 14000
2017 121 8000
2017 120 5000
2017 120 5000
2017 120 4000
2017 120 5000
2017 120 3000
2017 120 4000
2017 120 4000
2017 120 4000
2017 119 6000
2017 119 6000
2017 119 4000
2017 119 5000
2017 119 5000
2017 119 7000
2017 119 7000
2017 119 6000
2017 16 20000
2017 16 15000
2017 16 20000
2017 16 15000
end
[/CODE]

回答 (2 件)

Voss
Voss 2024 年 8 月 21 日

Ronit
Ronit 2024 年 8 月 22 日
Hello Saptorshee,
To calculate the mean of the variable a25 grouped by the variables a6a7 and year in MATLAB, you can use the groupsummary function. First, you'll need to create a table from your data, then use this function to compute the mean.
% Load and extract the data matrix from the .mat file
loadedData = load("datafile.mat");
data = loadedData.data;
% Convert the data to a table
T = array2table(data, 'VariableNames', {'Year', 'A6A7', 'A25'});
% Use groupsummary to calculate the mean of A25 grouped by Year and A6A7
result = groupsummary(T, {'Year', 'A6A7'}, 'mean', 'A25');
disp(result);
Year A6A7 GroupCount mean_A25 ____ ____ __________ ________ 2017 16 4 17500 2017 17 24 12729 2017 119 8 5750 2017 120 8 4250 2017 121 56 11536
Here is the documentation link of groupsummary function for more details: https://www.mathworks.com/help/matlab/ref/double.groupsummary.html
I hope it helps you query!
  1 件のコメント
SAPTORSHEE KANTO
SAPTORSHEE KANTO 2024 年 8 月 22 日
Thank you very much indeed.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by