Hi, I have this code, and is getting warnings about pre-allocation to speed up in this variables:numdia,mediasDiarias, how can I pre-allocate this 2 variables, to stop the warning, this is driving my crazy, because I hate warnings, and I tried a lot to the warning disappear.
function [mediasDiarias,mesano,numdia]=perfilhorariosmensal(valores,ano,mes,hor)
mediasDiarias = [];
numdia = [];
mesano{1} = 'HORAS';
contMeses =2;
k=1;
while k<size(valores,1)
som = zeros(24,1);
cont = zeros(24,1);
if ~isnan(valores(k))
som(hor(k)+1) = valores(k);
cont(hor(k)+1) = 1;
end
k=k+1;
while ( ano(k) == ano(k-1) ) && ( mes(k) == mes(k-1) )
if ~isnan(valores(k))
som(hor(k)+1) = som(hor(k)+1) + valores(k);
cont(hor(k)+1) = cont(hor(k)+1) + 1;
end
k=k+1;
if k == size(valores,1)
break;
end
end
mesano{contMeses} = [n2s(mes(k-1),'%02d') '/' n2s(ano(k-1),'%04d')];
mediasDiarias = [mediasDiarias som./cont];
numdia = [numdia (sum(cont)/24)];
contMeses=contMeses+1;
end
end
0 Comments
Sign in to comment.