MEAN OF A VARIABLE WITH RESPECT TO OTHER VARIABLES
2 views (last 30 days)
Show older comments
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]
0 Comments
Answers (2)
Ronit
on 22 Aug 2024
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);
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!
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!