Select the correct data from matrix

5 ビュー (過去 30 日間)
stelios loizidis
stelios loizidis 2020 年 6 月 11 日
コメント済み: Rik 2020 年 6 月 12 日
Hello. I have the following problem: For a product I predict the prices it will have the next day (24 prices). I use 5 models to predict. So I have 5 different predictions. I put these predictions in a matrix A (1X120). Next, I calcuate the error resulting between the acual values and the predicted values of each model and place the results in matrix B (24X5). Then, I select the smallest error for each one hour out of 24 and I put the result in matric C(1X24). What I am trying to do is in another matrix (for example D) to set the prediciton values that correspond to each error from matrix C. But beacuse the errors are different evry time I run the code, how can I find the corresponding values from matrix A? Your help is important!!!!

回答 (1 件)

Rik
Rik 2020 年 6 月 11 日
You're probably using min to select the smallest value, so you should use the second output to find the index of those values. Then you can use those col indices to find the linear indices in A.
  4 件のコメント
stelios loizidis
stelios loizidis 2020 年 6 月 12 日
I have read the documentation of min function. However, what I am trying to do is to have a separate matrix for each minimum error in matrix C, to have the corresponding value provided by matrix A. Below I put a piece of code
A=[]; % 1X120: predicted values
B=[]; % there errors:Actual values-Predicted Valeus
for i=1:24
C(i)=min(B(i,:)) % In matrix C there are the small error from each row of matrix B
end
Rik
Rik 2020 年 6 月 12 日
You can use the second output argument of min to find the index that contains the minimum value. If you know how the positions in B relate to the positions in A, you can use that to translate those indices in B to indices in A.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by