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

20 次查看(过去 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 CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by