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

4 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

Matt J
Matt J il 21 Set 2025
Modificato: Matt J il 21 Set 2025
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 Commenti
Irina
Irina il 21 Set 2025
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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Just for fun in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by