How to post process each variable in a mat file ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shekhar Vats
am 11 Jul. 2019
Beantwortet: Shekhar Vats
am 12 Jul. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 11 Jul. 2019
S = load(filename)
fn = fieldnames(S)
Fc = length(fn)
for k = 1 : Fc
F = fn{k}
Data = S.(F)
Process Data
end
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!