Error when adding values to array in loop

4 次查看(过去 30 天)
I'm trying to add the mean and standard deviation values of a timeseries in a loop to the proper arrays, however i am running into the same error in the multiple ways i'm trying to do it. Here's the code:
for i=31:30:length(TotalReadingsB)
MediaMatriz = [MediaMatriz mean(TotalReadingsB(i-30:i))] %Média de cada mês
SMatriz = [SMatriz std(TotalReadingsB(i-30:i))] %Desvio padrão de cada mês
end
The series contains data for a year and the objective is to collect the the aboce mentioned valued monthly.
This results in the fallowing error:
Dimensions of matrices being concatenated are not consistent.
  4 个评论
Walter Roberson
Walter Roberson 2018-4-26
MediaMatriz;
does not initialize: it causes MediaMatriz to be looked up in the symbol table, gives an error if it is not found, then because of the ';' it discards the output of displaying MediaMatriz .
You need an initialization, something like
MediaMatriz = [];

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by