How to post process each variable in a mat file ?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-7-11
S = load(filename)
fn = fieldnames(S)
Fc = length(fn)
for k = 1 : Fc
F = fn{k}
Data = S.(F)
Process Data
end
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!