To make vector compatible to matrix.

1 回表示 (過去 30 日間)
tejasvee
tejasvee 2017 年 4 月 20 日
回答済み: Walter Roberson 2019 年 5 月 3 日
I have code for disease prediction in which It is equation w = (H'*H+l1*eye(nh,nh))\(H'*Data.y);in which 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.It is in trainRELM.m . trainRELM is function which is called in main.m I have attched the code and dataset.

採用された回答

Roger Stafford
Roger Stafford 2017 年 4 月 20 日
If Data.y is a vector, to make the matrix multiplication H'*Data.y valid, it must be a column vector with the same number of elements as there are columns in H’. That is, size(Data.y) must equal [size(H’,2),1].
  2 件のコメント
tejasvee
tejasvee 2017 年 4 月 20 日
but H' is of size 100*303 due to size of data set. i have checked the size of H' using size(H'). or you want to tell me that size(H') and size of (Data.y) must be equal.
Roger Stafford
Roger Stafford 2017 年 4 月 20 日
編集済み: Jan 2017 年 4 月 20 日
No, I didn’t say that. What I have said is that size(Data.y) must equal [size(H’,2),1]. That means that Data.y must have the same number of rows as H’ has columns. Otherwise the expression H'*Data.y will be invalid. Check the site
I also stated that Data.y should have one column because earlier you said that it was a vector. For the purpose of making the above multiplication valid it can actually have any number of columns.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 5 月 3 日
y is read from columns O P Q R S of the csv file. Those columns are all empty in the supplied csv file so requesting them would temporarily fill them with NaN. If you were using xlsread it would trim away all leading and trailing rows and columns that are all nan which would leave you with emptiness. With csvread it will probably return a 240 x 5 column of nan. However as Roger explained the code can only work when y is a column vector - in this case a column vector with 240 rows .
In the larger scheme even if the number of rows and columns were correct your target information would all be nan and it is not possible to train your classes when you do not have target information.

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by