Renaming loaded variable with initially unknown name
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pratyay Sengupta
el 30 de Mzo. de 2021
Comentada: Stephen23
el 31 de Mzo. de 2021
Hello All,
Currently I am working with genome scale models. So, I have .mat files of those models. After loading the files, I get random variables (suppose: xyz, data type: 1x1 struct) in my workspace. I want to fetch variables inside the loaded variable. Like xyz.reactions or xyz.genes. But I am unable to get the name 'xyz'. How can I rename them automaically without knowing the variable names?
I tried > model = load('filename.mat'); but this creates a struct with the unknown name inside model, so unable to fetch variables in it.
Any suggestions would be highly appreciated!
Thanks!
1 comentario
Respuesta aceptada
Steven Lord
el 30 de Mzo. de 2021
data = load('census.mat')
variableNames = fieldnames(data)
dataFromVariable1 = data.(variableNames{1})
fprintf('Variable %s from census.mat is %s\n', variableNames{1}, mat2str(dataFromVariable1))
Más respuestas (0)
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!