Divide y values of two graph?

조회 수: 5 (최근 30일)
Muhammad Rizki Nasution
Muhammad Rizki Nasution 2018년 6월 20일
댓글: Alireza Qaderi 2021년 2월 3일
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
Ankita Bansal
Ankita Bansal 2018년 6월 20일
Your question is a bit unclear. Can you give more information?

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

채택된 답변

Sayyed Ahmad
Sayyed Ahmad 2018년 6월 20일
what about htis?
x=1:20;
x2=1:5:20;
y1=x.^2;
y2=x2.^3-x2.^2+0.5*x2;
plot(x,y1,'b-',x2,y2,'g.-')
y3=interp1(x2,y2,x);
hold on;
plot(x,y1,'b-',x,y3,'r*')
  댓글 수: 2
Muhammad Rizki Nasution
Muhammad Rizki Nasution 2018년 6월 20일
thanks, it works
Alireza Qaderi
Alireza Qaderi 2021년 2월 3일
Great

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

추가 답변 (1개)

Steven Yeh
Steven Yeh 2018년 6월 20일
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.

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by