How to combine 2 Matlab figure plots?
Show older comments
I have created 2 lines on the same plot. I need to take an average of them and add a 3rd line on this figure. Any idea how may I easily do so ? I am attaching the .fig (test_combine.fig) file as well.

Thanks
Accepted Answer
More Answers (1)
Raheel Naveed
on 24 Jul 2023
Greetings,
You can take average of data along Y-axis using mean() function.
Assuming your , y-axis data as y1 and y2, we can use below code to create a 3rd graph on same figure
hold on % to plot on same figure
yAvg=mean([y1:y2]) % You can replace your variables here
In case, there's still any problem, share the whole code for better debugging (or .mat file )
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
