plot average for multiple curves with different lengths

조회 수: 6 (최근 30일)
Isabel Schreiber
Isabel Schreiber 2018년 9월 4일
댓글: Isabel Schreiber 2018년 9월 5일
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

답변 (1개)

Image Analyst
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
Image Analyst
Image Analyst 2018년 9월 5일
Just check if the xAxis values are more than the max x for each signal.
Isabel Schreiber
Isabel Schreiber 2018년 9월 5일
Thank you for your help. I will get back to this question if I make any progress.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by