finding the mean based on a specific value in other column
4 ビュー (過去 30 日間)
古いコメントを表示
How do I find the mean of the temperature at the 6th Month of the year?
0 件のコメント
回答 (2 件)
Vilém Frynta
2022 年 11 月 29 日
編集済み: Vilém Frynta
2022 年 11 月 29 日
Find months that == 6 with function find(). Then use index of this function to get the temperatures. Then use mean() on these temperatures.
Example:
% Creating random table to work with (similar to your table)
T = table();
T.Day = [1:1:17]';
T.Month = [1 2 3 4 4 5 6 6 6 6 7 8 9 10 11 11 12]';
T.Temperature = randi([29 32],17,1)
% Find position of all rows where Month == 6
idx = find(T.Month==6)
% Use idx to get all the temperatures
idxTemperature = T.Temperature(idx)
% Calculate mean
meanTemperature = mean(idxTemperature)
Edit: added an example
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!