Divide y values of two graph?
Show older comments

i want to divide y values of the orange line by the blue line with the same x value, but x values have different point so they have different matrix size, i'm a noob, could you help me?
1 Comment
Ankita Bansal
on 20 Jun 2018
Your question is a bit unclear. Can you give more information?
Accepted Answer
More Answers (1)
Steven Yeh
on 20 Jun 2018
You could create a new time series, and use linear interpolation to find corresponding values.
For example:
ax = linspace(0, 10, 20);
ay = ax;
bx = linspace(0, 10, 30);
by = bx/2;
timeSeriesWanted = linspace(0, 10, 1000);
ay_interpolated = interp1(ax, ay, timeSeriesWanted);
by_interpolated = interp1(bx, by, timeSeriesWanted);
ay_dividedBy_by = ay_interpolated ./ by_interpolated;
plot(ax, ay,'*-')
hold on
plot(bx, by,'*-')
plot(timeSeriesWanted, ay_dividedBy_by, '-');
legend('a', 'b', 'a/b with interpolation')
Assuming your original data series are (ax, ay) and (bx, by), you can create new series by calling interp1.
1 Comment
Muhammad Rizki Nasution
on 20 Jun 2018
Categories
Find more on Interpolation 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!