How to take the difference of y axis points at the same value of x-axis from 2 curve at the same graph?
5 次查看(过去 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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!