Create for loop to read in multiple excel files

3 ビュー (過去 30 日間)
OliK
OliK 2015 年 10 月 8 日
回答済み: dpb 2015 年 10 月 8 日
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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by