MATLAB Answers

how to call multiple access file from one folder in matlab

5 views (last 30 days)
Ali Asghar
Ali Asghar on 22 Sep 2019
Commented: Rik on 23 Sep 2019
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?

Answers (1)

Shubham Gupta
Shubham Gupta on 23 Sep 2019
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 Comments

Show 2 older comments
Rik
Rik on 23 Sep 2019
Then you should replace load with a function that can load Microsoft Access Table files.
Stephen Cobeldick
Stephen Cobeldick on 23 Sep 2019
And use fullfile instead of concatenating strings together.
Rik
Rik on 23 Sep 2019
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

Sign in to comment.