Hi, I have a data bases, I should calculed the mean of month of each years.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Julian david ortiz umaña
am 21 Okt. 2022
Beantwortet: Vishesh
am 25 Okt. 2022
Hi, I have a data bases, I should calculed the mean of month of each years.
My error this:
Index in position 2 is invalid. Array indices must be positive integers or logical values.
thanks
Akzeptierte Antwort
Vishesh
am 25 Okt. 2022
- You can use the following code for calculating mean of months of each years.
Teje2=load("Ej.2.TempTacSalto.mat");
Temsalor=flipud(Teje2.tempsalto);
anos=[1990:2019];%define vector de años
lanos=length(anos);%cantidad de años
meses=[1:12];%define vectos meses
lmeses=length(meses);%cantidad de meses
tsalm=[];%inicializa cantidad de promedios
ldat=length(Temsalor(:,4));%cantidad de datos
for j=1:length(anos)%obtiene promdeio de cada mes
for b=1:12
year= Temsalor(:,3)==anos(j);
month= Temsalor(:,2)==b;
tsalm=[tsalm mean(Temsalor(:,4).*month.*year)*length(Temsalor)/sum(month.*year )];
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!