Error using bsxfun??

1 回表示 (過去 30 日間)
Oman Wisni
Oman Wisni 2018 年 11 月 24 日
編集済み: Oman Wisni 2018 年 11 月 25 日
Hi, I want to display the results of the calculations that I made, I want to add two values with different matrix sizes, I use 2 ways by adding regular (+) and using bsxfun. But both errors. have code like below :
D = 25 ;
K = 11;
h = 100;
reg = 0.01;
iteration=1000;
w1 = 0.01*randn(D,h);
w2 = 0.01*randn(h,K);
a = 0.5.*reg.*(W1.*W1);
b = 0.5.*reg.*(W2.*W2);
reg_los1 = a+b;
reg_los = bsxfun(@plus, a,b);
for i = 1:100;
fprintf('Iteration: %d \n' , i);
end
If there are another way to fix, I hope someone can improve my code, thank you.
  1 件のコメント
Jan
Jan 2018 年 11 月 24 日
Please do not post just "But both errors", but pos the complete error messages in the forum. It is easier to fix a problem than to guess, what the problem is.

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

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 24 日
編集済み: madhan ravi 2018 年 11 月 24 日
Try :
D = 25 ;
K = 11;
h = 100;
reg = 0.01;
iteration=1000; % i can't see this being used anywhere?
w1 = 0.01*randn(D,h);
w2 = 0.01*randn(h,K);
a = 0.5.*reg.*(w1.*w1); % -> matlab is case sensitive
b = 0.5.*reg.*(w2.*w2);
reg_los1 = a+b; %remove this line because im not sure this will work in previous versions
reg_los = bsxfun(@plus, a,b);
for i = 1:100;
fprintf('Iteration: %d \n' , i);
end
  9 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 25 日
please use google before asking , type argmax matlab and mean matlab you will find the answer in the first link
Oman Wisni
Oman Wisni 2018 年 11 月 25 日
編集済み: Oman Wisni 2018 年 11 月 25 日
already asking google, but I don't understand. Yes I will try ask again.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by