The variable Edj appears to change size consider preallocating

2 ビュー (過去 30 日間)
Jacob Muvingi
Jacob Muvingi 2020 年 1 月 1 日
コメント済み: Jacob Muvingi 2020 年 1 月 3 日
VV(1:size(temp,1),d)=temp;
for j=1:n
E(d,j) = y(j,:)*VV(s+1:s+m,d) / (x(j,:)*VV(1:s,d));
end
Ecros =sum(Edj)/n
End

採用された回答

Gifari Zulkarnaen
Gifari Zulkarnaen 2020 年 1 月 1 日
編集済み: Gifari Zulkarnaen 2020 年 1 月 3 日
The size of your matrix changes at every iteration. Make zero matrix before looping. For example:
Edj = zeros(d,n);
*edited for corrections from Image Analyst and Jacob Muvingi
  5 件のコメント
Stephen23
Stephen23 2020 年 1 月 3 日
編集済み: Stephen23 2020 年 1 月 3 日
"So should I write Edj=zeros(d,n);"
No, you should write what Image Analyst told you.
"I am still getting the same error..."
It is a warning, not an error.
"...after I have done the following;"
Array preallocation needs to be before the loop, e.g.:
E = zeros(d,n);
for j = 1:n
E(d,j) = ...
end
Jacob Muvingi
Jacob Muvingi 2020 年 1 月 3 日
The issue of preallocation seem to have resolved, however getting message Matrix dimensions must agree referring to line for calculation of E(d,j). My matrices are of different sizes, y is 1*12, x is 2*12. V are weights for each x and y value.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by