Create for loop to read in multiple excel files
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
dpb
el 8 de Oct. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!