"Jelle" wrote in message <firstname.lastname@example.org>... > I changed the script to optimize both the short and long period moving average: > > sh = nan(100,100); > > for n = 1:100 > for m = n:100 > [~,sh(m)] = movavg(Data.Closing(:,1), n, m) > end > end > > However I still get > > ??? In an assignment A(I) = B, the number of elements in B and I must be the same.
You should take error messages very literally. sh(m) is a number, while i suspect that the right hand side is vector/matrix, ie. the number of elemens are not the same
if you try: [~,temp] = movavg(Data.Closing(:,1), n, m) and then but a break after that line (click in left margin, till red dot appears) then run the code. you will now see what the size of temp is. this is also the size that sh(m) should have.
(afterwards go to "exit debug mode" in dropdown menu 'debug')