Find the average curve of multiple plots from different Excel files
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sruthi Geetha
2017-7-17
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!