How to import multiple excel files and pull data
Mostrar comentarios más antiguos
I am trying to pull multiple files from excel and extract data to create a plot, however I am not getting the plot. Below is my code:
clear all; clc
[file_list, path_n] = uigetfile ('.xlsx','Grab the files you want to proocess', 'Multiselect', 'on');
if iscell(file_list) == 0
file_list = (file_list);
end
for i = 1:length(file_list)
data_in{i} = xlsread([path_n file_list{i}]);
p1{i} = data_in{i}(:,2);
p2{i} = data_in{i}(:,1);
p3{i} = data_in{i}(:,3);
p_avg{i} = ((p1{i}+p2{i}))./2;
cp_a{i} = (p3{i}-p2{i})./(p1{i}-p_avg{i});
if rem(i,2) == 0.
cp_avg_max{i} = max(cp_a{i});
else cp_avg_max{i} = min(cp_a{i});
end
figure
alpha = -10:1:10
plot (alpha, cp_avg_max{i});
end
4 comentarios
Mathieu NOE
el 14 de Dic. de 2020
hello
do you have a couple of excel files to share , to test your code ?
Christina Reid
el 14 de Dic. de 2020
You could read the x values from the file names:
...
end
% trim the extensions, then convert to array of doubles
x = str2double(extractBefore(file_list,'.x'));
plot(x,cp_a_min)
Christina Reid
el 15 de Dic. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!