How to take the difference of y axis points at the same value of x-axis from 2 curve at the same graph?

조회 수: 7 (최근 30일)
Hi,
I am struggling to take a difference between 2 y axis points at the same x axis value from 2 curve.
1st Curve:
x = [20,30,40,50,60,70,80,90,100]
y = [260,350,470,610,625,675,695,750,800]
%Plotting the points on the graph
plot(x,y,'x','LineWidth',3)
line (x,y,'Color','k','LineStyle','--','LineWidth',1)
hold on
2nd Curve:
for i = 2:length(q)
Q = q(i) ;
if h(i-1) < h1
v_2 = ((Q/1000) / Area_Outlet1);
h(i) = 75+((1 / (rho * g)) * (Patm2 - Patm1 + 0.5 * rho * (v_2^2 - v_1^2)) + h_f)*1000
else
v_2a = ((Q/1000) / Area_Outlet2);
h(i) = 75+h1 + ((1 / (rho * g)) * (Patm2 - Patm1 + 0.5 * rho * (v_2a^2 - v_1^2)) + h_f)*1000
end
end
plot(q,h)
hold off
Second curve plotted by using the loop. I want to find out what are the y-axis points at x = [20,30,40,50,60,70,80,90,100] for both curves.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 5일
You can use interp1()
h_new = interp1(q, h, x); % h_new are values at q=20,30,40,...,100

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by