how to call multiple access file from one folder in matlab

1 次查看(过去 30 天)
dear
1- I have one folder called 0 degree and in it i have multiple files (snapshot attached).
2- When I open HG file in matlab it give multple data in workspace and from it i want to select dath001 (24000x1) file.
3- i created file called filtering4.m in which i call dath001 and take some feature out of it......
clear all, close all, clc
load ('dath001.mat');
x = dath001;
Fs = 10e3;
for i = 1:4
waveLen(i) = find_waveform_length(x(:,i))
MAV (i)=find_MAV(x(:,i),2.4e4)
end
HG0_extracted_feature = [waveLen; MAV]; % size 2x4
I want to call each file like HG, HO,...WF in my matlab file called filtering4.m and do same activity to extract feature and ultimately all data store in HG)_extracted_feature so its size become 10x4.
How would i do this?

回答(1 个)

Shubham Gupta
Shubham Gupta 2019-9-23
One of the several ways to do this :
clear all, close all, clc
PathName = 'C:\Users\.......\0 degree\'; % Set the path where files are present
Files = {'HG','HO','Rest','WE','WF'};HG0_extracted_feature=[];
for i = 1:size(Files,2)
load([PathName,Files{i},'.mat']);
x = dath001;
Fs = 10e3;
for j = 1:4
waveLen(j) = find_waveform_length(x(:,j))
MAV (j)=find_MAV(x(:,j),2.4e4)
end
HG0_extracted_feature = [HG0_extracted_feature;waveLen; MAV];
end
save HG0_extracted_feature HG0_extracted_feature
I hope it helps !
  5 个评论
Rik
Rik 2019-9-23
And reconsider the usefulness of clear all, close all, clc. Do you really need to reload all functions from disk? Do you really need to close any open figure? Do you require a blank command window?
clear all % high performance penalty, unloads *everything*, don't use it
clearvars % useful for debugging: clears only variables
clear % equivalent to clearvars
close all % medium perfomance penalty (generally not needed),
% not useful if you don't open figures in your code
clc % almost no performance penalty, usefull if you expect errors/warning
% or expect something to be printed to the command window

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by