Find the average curve of multiple plots from different Excel files
4 views (last 30 days)
Show older comments
Carla Baceanu
on 14 Jul 2017
Commented: Carla Baceanu
on 17 Jul 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 Comments
Accepted Answer
Sruthi Geetha
on 17 Jul 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
More Answers (0)
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!