필터 지우기
필터 지우기

How can i make an average plot of 2 unequal data sets?

조회 수: 10 (최근 30일)
aditya palawat
aditya palawat 2019년 2월 21일
댓글: aditya palawat 2019년 3월 1일
Hi all,
I have data from 2 different experiments i conducted. As can be seen in the picture i have data set1 and data set2 and their corresponding plots. Now i wish to make a plot which is roughly an average of the two data sets but the data points i have are unequal so i do not know how to take a mean of the two or make confidence interval maybe. I would be grateful for any suggestions, thanks.
  댓글 수: 2
dpb
dpb 2019년 2월 22일
Interpolate the two with perhaps some smoothing to a common matching set of independent variable values and then average those results.
aditya palawat
aditya palawat 2019년 2월 22일
Hi dpb, thanks for the reply. can you please guide me a bit with a simpler example or piece of code? i am only a beginner in matlab,thanks.

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

채택된 답변

Krishna Zanwar
Krishna Zanwar 2019년 2월 26일
Hey Aditya,
This problem can be solved by 1D interpolation,
Let the X axis limits be 'Xmin', 'Xmax'.
And the data of X and Y axis be stored in 'X_data' , 'Y_data'.
For the second signal let them be stored in 'X_data_1' , 'Y_data_1';
You can sample the data at interval of 'X_int'.
Now
Xnew=Xmin:X_int:X_max;
Ynew=interp1(X_data,Y_data,Xnew);
You can follow the same procedure for 2nd data set.
Ynew_1=interp1(X_data_1, Y_data_1, Xnew);
Now you can get the average Yavg as-
Yavg=(Ynew+Ynew_1)/2;
And plot it against Xnew-
plot(Xnew,Yavg)
More information on 1D interpolation can be found here.
Hope this helps.
  댓글 수: 1
aditya palawat
aditya palawat 2019년 3월 1일
Hi krishna, thanks for the asnwer. I was able to get the average!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by