- Made the maximum loop index smaller from 100 to 5.
- To check the mat-file was loaded correctly, created the variable, filename.
- Since the first loading part worked correctly, checked the second part.
load multiple .mat file and do same calculation on each file
1 次查看(过去 30 天)
显示 更早的评论
i have 100 .mat file name "A00001-A00100". i want to create loop that do calculation (written in code) one by one on each file but my code just do calculation on first file (A00001.mat) only. please help!,
% loop to do same calculation on each file,
for i=1:100
load(['A000' num2str(i,'%02d') '.mat' ]);
%calculations
N=9000;
gqrs('A00001',N);
ann=rdann('A00001','qrs',[],N);
[tm,sig]=rdsamp('A00001',[],N);
end
0 个评论
采纳的回答
mizuki
2017-5-6
Your code works only for A00001 because you set 'A00001' as input arguments for GQRS, RDANN, RDSAMP. Change the numbers with index i.
for i=1:5
str = 'A000' num2str(i,'%02d');
filename = [str, '.mat']
load(str);
% calculations
N = 9000;
gqrs(str, N);
ann = rdann(str, 'qrs', [], N);
[tm,sig] = rdsamp(str, [], N);
end
Also, if you breakdown the problem, you can easily find which part you need to change.
更多回答(1 个)
Navdeep Goel
2019-9-29
for i=1:5
str = 'A000' num2str(i,'%02d');
filename = [str, '.mat']
load(str);
% calculations
N = 9000;
gqrs(str, N);
ann = rdann(str, 'qrs', [], N);
[tm,sig] = rdsamp(str, [], N);
end
In the above code, load(str) should be load(filename)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!