Trying to store data
Ältere Kommentare anzeigen
Unable to perform assignment because the size of the left side
is 1-by-2298 and the size of the right side is 3-by-3.
Hey was just wondering if anyone could help me sort this. I am trying to calculate fores. I have a 3x3x766 matrix and am trying to generate a forecast using a loop but can't manage to make the left side the same as the right side.
% Length of window
initwin = 500;
% Total no of forecasts made
nfore = n - initwin;
% Store forecasts and target
fores = zeros(3,3,nfore);
target = zeros(nfore,3);
for i = 1:nfore;
rtmp = rets(i:i + initwin - 1,:);
% Extract full smoothed vol from estimation
portfolio_smoothed=ewma_multi(rets);
vol_smoothed = ewma_multi(rtmp);
finaldays=vol_smoothed(:,:,initwin);
Et=rtmp(initwin-1,:)'*rtmp(initwin-1,:);
% Generate forecast
fores(i,:)=smooth*finaldays+(1-smooth)*Et;
target(i,:)=rets(i+initwin,:);
end
Antworten (1)
Torsten
am 21 Okt. 2022
fores(i,:)=
"fores" has three dimension, thus fores(i,i,:) ? I don't know where you want to save what and if the dimensions fit now.
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!