Create for loop to read in multiple excel files

1 次查看(过去 30 天)
Have this as my code so far:
%%Clear the workspace
clc;
clear all;
close all;
%%Import Data
imp = xlsread('HiG_67.csv','J:J'); %Import 'x ACC' Data
FilterValue=30; %Filter values less than 30
imp(imp<FilterValue)=0; %Set values less than 30 to 0
time= xlsread('HiG_67.csv','C:C')'; %Create time variable
%%Plot data and Calculate mean/SD
plot(time,imp) %Plot time against filtered data
n=sum(imp~=0); %Calculate mean of filtered data
n(n==0) = NaN;
m = sum(imp) ./ n;
sd=sqrt(sum(imp.^2)./sum(imp~=0) - m.^2); %Calculate Standard Deviation
%%Output data into Excel file
filename = 'Filter_67.csv';
xlswrite(filename,imp);
Now I would like to create a loop to read in 28 .csv files from the same folder, they are all titled 'HiG_**.csv' ( being 67-94). If I could then filter them all then output them as 'Filter_**.csv'
Thanks

回答(1 个)

dpb
dpb 2015-10-8
See the FAQ How can I process a sequence of files? I'll note I'm particularly fond of the dir solution for processing the input files in cases such as you've outlined.

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by