Loop through files of different length
3 ビュー (過去 30 日間)
古いコメントを表示
I am trying to loop through some data files of differing length, but at the moment I have to set the length manually for each file, so my code keeps breaking:
hrsInf(1,1) = sum(ECGdata(1:h,1)==0)/h*100;
hrsInf(2,1) = sum(ECGdata(h+1:2*h,1)==0)/h*100;
hrsInf(3,1) = sum(ECGdata(2*h+1:3*h,1)==0)/h*100;
hrsInf(4,1) = sum(ECGdata(3*h+1:4*h,1)==0)/h*100;
hrsInf(5,1) = sum(ECGdata(4*h+1:5*h,1)==0)/h*100;
hrsInf(6,1) = sum(ECGdata(5*h+1:6*h,1)==0)/h*100;
and so on, where h is one hour (with a 250psec sampling rate). How can I loop through each file to the maximum number of whole hours?
0 件のコメント
採用された回答
dpb
2022 年 10 月 6 日
When you compute what h is in samples (if sample rate varies, otherwise just set it as a constant), then
[R,C]=size(ECGdata);
N=fix(R/h);
tmp=reshape(ECGdata(1:N*h,1),h,[]);
hrsInf=sum(tmp==0)/h*100;
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!