フィルターのクリア

error in the code not getting removed

1 回表示 (過去 30 日間)
tejasvee
tejasvee 2017 年 4 月 14 日
コメント済み: tejasvee 2017 年 4 月 18 日
Hello Experts, I have code in which it gives error of "Error of inner matrix dimension". i have checked many of answers in the group asked by others and tried but it is not getting removed. Help me to remove this error.If i comment that line of code it runs.Error is not in "main.m" program but it is in "trainRELM.m" line no 87. While i run the main.m it gives error Error using * Inner matrix dimensions must agree.
Error in trainRELM (line 87)
w = (H'*H+l1*eye(nh,nh))\(H'*Data.y);
is main cause of error
Error in Main (line 47)
LR2 = trainRELM(DataTG,Params);
I have attached the code and dataset.

採用された回答

dpb
dpb 2017 年 4 月 14 日
You have two matrix multiplications in the offending line H+l1*eye(nh,nh))\(H'*Data.y);
So, the problem is one of the following:
  1. Variable i1 is a not square(*), or
  2. size(H',2) ~= size(Data.y,1)(*), or
  3. didn't intend to use matrix multiplication but element-wise which is the "dot" operator ".*"
Don't know which of the above is the actual case nor necessarily the answer you need as didn't try to read the code but looking through your algorithm for the intended result ensuring that you can actually perform a legal matrix multiplication if that's what is wanted or if it is computation in the numerator/denominator of the expression that is supposed to be element-by-element, then fix the operator to do that instead.
() Matrix multiplication requires A*B have dimensions such that are [m x n][n x q] with result of [m x q].
  7 件のコメント
tejasvee
tejasvee 2017 年 4 月 17 日
Thankyou Sir for reply, I figured out that there is error in inner matrix dimension due to (H'*Data.y); in the below equation as H' is of dimension 100*303 and Data.y is of 0. i checked the size of Data.y w = (H'*H+l1*eye(nh,nh))\(H'*Data.y); But i can't understand how to make it of dimension 303*n as Data.y is is the vector of labels, either regression or classification labels (+1,-1) then how it could be of dimension 303*n or something else.
tejasvee
tejasvee 2017 年 4 月 18 日
Sir in the last query , i asked you for data.y is not compatible for matrix multiplication. As it is vector of labels, either regression or classification labels (+1,-1) so i converted it to matrix by using Data.y=vec2mat(Data.y,297) to make it compatible but again there is same error of inner matrix dimension. What should i do to make it compatible. https://in.mathworks.com/matlabcentral/answers/335348-error-in-the-code-not-getting-removed

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

その他の回答 (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