plot average for multiple curves with different lengths
6 次查看(过去 30 天)
显示 更早的评论
I plotted multiple curves in the same plot and would like to calculate and plot an average of those. The problem is, that they have different lengths - meaning some have above 280 lines while others have only 120. I've found several suggestions to work with interp1, create a separate y vector and plot the average x values accordingly. However, the suggested codes that I found didn't work for me or since I'm a beginner, I wasn't really able to adapt them to my specific case.
This what I have so far:
%%load replicate measurements 1-6 in workspace
% define variables
% define 1. deployment
force = TauM1 (:,2);
depth = TauM1 (:,1);
x1 = force;
y1 = depth;
% define 2. deployment
force = TauM2 (:,2);
depth = TauM2 (:,1);
x2 = force;
y2 = depth;
...did that for all 6 measurements...
%%plot all 6 replicate deployments in one line plot
plot (x1,y1)
hold on
plot (x2,y2)
hold on
plot (x3,y3)
hold on
plot (x4,y4)
hold on
plot (x5,y5)
hold on
plot (x6,y6)
hold off
How would I be able for example to create a separate y vector from 0 to 55 and then average the interpolated x values from all 6 curves?
Thanks in advance
0 个评论
回答(1 个)
Image Analyst
2018-9-4
you forgot to attach your data and screenshots of your plots. About all I can say is to sum up your 6 y signals and divide by 6.
Possible solution:
yAverage = (y1+y2+y3+y4+y5+y6)/6;
plot(yAverage, 'k-', 'LineWidth', 3);
grid on;
7 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
