How to combine two functions in one graph?
Show older comments
How do I combine two functions in one graph and find the average value of that graph. The first function ranges from 0 to 85 degrees and the other one from 85 to 180 degrees.
Answers (2)
José-Luis
on 6 May 2013
hold on
Jan
on 6 May 2013
The more details you post, the less we have to invent.
x = 1:100;
y1 = rand(1, 100) * 85;
y2 = rand(1, 100) * 95 + 85;
plot(x, y1, x, y2);
% Or:
AxesH = axes('nextplot', 'add');
plot(AxesH, x, y1);
plot(AxesH, x, y2);
meanY = (y1 + y2) * 0.5;
Or perhaps "average value" means:
meanY = sum(y1 + y2) / (2 * length(x));
Categories
Find more on Just for fun 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!