Borrar filtros
Borrar filtros

NaNing correlation matrix values based on variable name

1 visualización (últimos 30 días)
Tamir Eisenstein
Tamir Eisenstein el 26 de Abr. de 2020
Editada: Stephen23 el 26 de Abr. de 2020
Hi MATLAB experts,
how can I set matrix values to NaN based on their variable name?
For example, I have a correlation matrix, and some of the variable names are john1, john2, john3.., bob1, bob2, bob3.., etc.
How can I implement that every correlation value that is not between two john* variables will be set to NaN?
Thanks!
  2 comentarios
Rik
Rik el 26 de Abr. de 2020
You forced yourself to write difficult and fragile code by having numbered variables. You should use an array instead, then you would probably be able to do it yourself.
Stephen23
Stephen23 el 26 de Abr. de 2020
Editada: Stephen23 el 26 de Abr. de 2020
"Hi MATLAB experts, how can I set matrix values to NaN based on their variable name?"
MATLAB experts will advise you to avoid forcing meta-data into variable names, and that your code would be much simpler and more efficient if you put all of your data into one array. If you follow their advice your task will be easy.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by