Trying to store data

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

回答 (1 件)

Torsten
Torsten 2022 年 10 月 21 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

jxl
2022 年 10 月 21 日

回答済み:

2022 年 10 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by