how to create the number of equations from a correlation matrix by excluding the most correlated variables?

19 ビュー (過去 30 日間)
I have a correlation matrix with several variables with different values. I would like to create all the pairs between the variables. In equestion i don't have to add the most correlated varaibles which are forbidden pairs (>0.5 and <-0.5)

採用された回答

Matt J
Matt J 2025 年 9 月 21 日 10:40
編集済み: Matt J 2025 年 9 月 21 日 10:43
That sounds like a bad idea. Normally, in MATLAB, you wouldn't write your equations in scalar form. You would write a matrix equation in terms of the covariance matrix itself, so that the variables don't have to be individually enumerated.
To zero out certain elements of the matrix, you can just do, e.g.,
Matrix=2*rand(5)-1
Matrix = 5×5
0.1437 0.0614 -0.0388 0.6845 -0.8494 -0.6830 0.8140 -0.5093 -0.0253 0.5441 0.8851 0.3720 0.1982 0.6276 -0.7369 -0.8184 -0.1437 0.0993 -0.0809 -0.5629 0.5320 -0.7783 0.3990 -0.5697 -0.5892
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Matrix(abs(Matrix)>0.5) = 0
Matrix = 5×5
0.1437 0.0614 -0.0388 0 0 0 0 0 -0.0253 0 0 0.3720 0.1982 0 0 0 -0.1437 0.0993 -0.0809 0 0 0 0.3990 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  2 件のコメント
Irina
Irina 2025 年 9 月 21 日 11:10
Thanks a lot Matt. i'm new in Matlab, now i got the point. By excluding the strong correlated variables i can only create combinations where i have values. But if i will create a sepparate excel file and upload in Matlab with already forbidden pairs. Like in lotto for example i have numbers (1-49) and i have to create all combinations with 6 numbers and the forbidden pairs would be the same number. This logic can be given by Matlab?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeJust for fun についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by