Create for loop to read in multiple excel files

3 vues (au cours des 30 derniers jours)
OliK
OliK le 8 Oct 2015
Réponse apportée : dpb le 8 Oct 2015
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

Réponses (1)

dpb
dpb le 8 Oct 2015
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.

Community Treasure Hunt

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

Start Hunting!

Translated by