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

조회 수: 6 (최근 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일
편집: Matt J 2025년 9월 21일
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일
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