Find the average curve of multiple plots from different Excel files
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Carla Baceanu
le 14 Juil 2017
Commenté : Carla Baceanu
le 17 Juil 2017
I have multiple excel files each having 2 columns, all numerical values. I have managed to make a plot which has all the lines superimposed, without actually extracting separate variables in the workspace. But now I need to find a line that is an average of all the other lines, and I can't figure it out. Might be more difficult since I don't have the variables extracted. This is the code. Thank you in advance!
Files = dir('E:\...');
N = length(Files);
for i = 3:N
m = sprintf('%s', Files(i,1).name);
Frequency = xlsread(m,'A:A');
Density = xlsread(m,'B:B');
plot(Density,Frequency)
hold on
xlabel('Density')
ylabel('Frequency')
xlim([0 1.4]);
ylim([0 7000]);
end
0 commentaires
Réponse acceptée
Sruthi Geetha
le 17 Juil 2017
You can find the sum of the frequency and density values for each file and then divide by N to get the mean of frequency and density respectively. Then plot them. It would look something like this:|
endFiles = dir('E:\...');
N = length(Files);
f = 0;
d = 0;
for i = 3:N
m = sprintf('%s', Files(i,1).name);
Frequency = xlsread(m,'A:A');
Density = xlsread(m,'B:B');
f = f + xlsread(m,'A:A');
d = d + xlsread(m,'B:B');
plot(Density,Frequency)
hold on
xlabel('Density')
ylabel('Frequency')
xlim([0 1.4]);
ylim([0 7000]);
end
fmean = f/N;
dmean = d/N;
plot(fmean,dmean);
hold off
1 commentaire
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!