How to take the difference of y axis points at the same value of x-axis from 2 curve at the same graph?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 5 Oct 2020
Réponse apportée : Ameer Hamza
le 5 Oct 2020
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 commentaires
Réponse acceptée
Ameer Hamza
le 5 Oct 2020
You can use interp1()
h_new = interp1(q, h, x); % h_new are values at q=20,30,40,...,100
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!