필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Help with Looping and Averages?

조회 수: 3 (최근 30일)
sharlyn gante
sharlyn gante 2016년 12월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
Any help will be great. I'm trying to calculate the average of something using a loop. For this question, I have to calculate the average of ice content within 6 different lakes (ice content is y-axis), each day (x-axis). For example, In Day 1: Lake1 has 6%, Lake 2 has 3%, Lake 3 has 6%, Lake 4 has 5%, Lake 5 has 3%, and Lake 6 has 6%. There is 120 days in one data file. I'm not very good at loops so I honestly only have
%% LOOP TEST
i = Day1; <--where Day1 is [1:120]

답변 (1개)

dbmn
dbmn 2016년 12월 1일
Here is a small script that should help you get started
ice = rand(6,10);
days = datetime(today)+days(1:10);
% Average over all 6 Lakes per day
average1 = mean(ice);
% Average over all 10 days per lake
average2 = mean(ice,2);
if you have multiple datasets of 150 days that you read in a loop, you can get the overall average by taking the average of the averages.
If the datasets have a different number of days, you can just take the sum of each file and divide that by the total number of days in the end.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by