Find the average curve of multiple plots from different Excel files
2 ビュー (過去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166034/image.jpeg)
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!