How to post process each variable in a mat file ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shekhar Vats
le 11 Juil 2019
Réponse apportée : Shekhar Vats
le 12 Juil 2019
I am trying to downsample all the variables in a mat file.
I can use downsample(var, newSampling) to downsample an individual variables but what to do if i need to downsample all the vectors in the mat file.
load ('my_mat_file_here.mat')
list_var = who; % to get the list of variables
for kk = 1:1:length(list_var) % to run the loop
% downsample(eval(list_var{kk}),10); <-- this part is working as expected with eval
[list_var{kk} '_1hz'] = downsample(eval(list_var{kk}),10);
end
% in this part how to define a new variable
% i am trying to use the variable name from list_var which is a character
% and add _1hs to ths string but matlab won't allow it to % be used as a varaible name
% trying to avoid using assignin & eval to assign the new variable to my base workspce
% any help appreciated.
0 commentaires
Réponse acceptée
Walter Roberson
le 11 Juil 2019
S = load(filename)
fn = fieldnames(S)
Fc = length(fn)
for k = 1 : Fc
F = fn{k}
Data = S.(F)
Process Data
end
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!