how to call multiple access file from one folder in matlab

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

Error using load
Unable to read file 'C:\Users\Amatullah\Dropbox\My eBooks\PhD\arrm position\Real experiments\Real experiments\Subject 1\0 degreesHG.mat'. No such file or directory.
Error in filtering4 (line 83)
load([PathName,Files{i},'.mat']);
dear
it shows above error.....
kindly note that HG,HO.....WF are microsoft access file....
I am so sorry. I assumed these to be "mat" files.
Then you should replace load with a function that can load Microsoft Access Table files.
And use fullfile instead of concatenating strings together.
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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Naming Conventions에 대해 자세히 알아보기

태그

질문:

2019년 9월 22일

댓글:

Rik
2019년 9월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by