How do i find the intersection between two curves?

3 views (last 30 days)
clear all
close all
d=10*10^-3; %----rördiameter i meter
L=20; %-----längd rör
ks=0.3; %----material
Q=0:0.1:2.5; %----volymflöde L/min
Qf=Q/(60*1000); %----gör om till m^3/s
ny=0.661*10^-6; %----kinematisk viskositet
ra=992.2; %-----densitet
r=(d/2)*10^3; %----rörradien i mm
engf=0; %------engångsförluster - påverkar dynamisk uppf.höjd
v=Qf*4/(pi*(d^2));
Red=v*d/ny;
if Red<2300
lam=64./Red;
else
lam=1./(1.8*log(6.9./Red+(ks/(7.42*r)).^1.11)).^2;
end
H=(1/(2*9.807)).*(v.^2).*(lam*L/d+engf); %Uppf.höjd Systemkurva
figure(1)
plot(Q,H, 'k','LineWidth',2); %Systemkurva
hold on
xlabel('Q Volymflöde [L/min]');
ylabel('H Uppfodringshöjd');
%Värden för pump 80 mm diameter
HE=[0.7
0.69
0.679
0.668
0.656
0.643
0.629
0.614
0.598
0.582
0.565
0.546
0.527
0.507
0.486
0.463
0.44
0.416
0.39
0.364
0.337
0.308
0.278
0.247
0.216
0.183];
plot(Q, HE, 'b', 'LineWidth',2); %Pumpkurva
Hi!
How do I find the exact coordinates for the intersection between those curves?
I've tried with intersect, but I can't get it to work!

Answers (1)

Stephan
Stephan on 2 Apr 2019
Edited: Stephan on 3 Apr 2019
Hi,
usually this can be aproximated with quadratic functions - so you can use polyfit and polyval to calculate functionsthe describing your system and the pump. After this the values are calculated by using this functions and added to the plot (drawn as squares in the corresponding color) - i think it is a good enough result. Now you know your system and your pump functions, which can be used in fzero to calculate the intersection point, that is shown by the red circle in the plot:
close all
d=10*10^-3; %----rördiameter i meter
L=20; %-----längd rör
ks=0.3; %----material
Q=0:0.1:2.5; %----volymflöde L/min
Qf=Q/(60*1000); %----gör om till m^3/s
ny=0.661*10^-6; %----kinematisk viskositet
ra=992.2; %-----densitet
r=(d/2)*10^3; %----rörradien i mm
engf=0; %------engångsförluster - påverkar dynamisk uppf.höjd
v=Qf*4/(pi*(d^2));
Red=v*d/ny;
if Red<2300
lam=64./Red;
else
lam=1./(1.8*log(6.9./Red+(ks/(7.42*r)).^1.11)).^2;
end
H=(1/(2*9.807)).*(v.^2).*(lam*L/d+engf); %Uppf.höjd Systemkurva
figure(1)
plot(Q,H, 'k','LineWidth',2); %Systemkurva
hold on
xlabel('Q Volymflöde [L/min]');
ylabel('H Uppfodringshöjd');
%Värden för pump 80 mm diameter
HE=[0.7
0.69
0.679
0.668
0.656
0.643
0.629
0.614
0.598
0.582
0.565
0.546
0.527
0.507
0.486
0.463
0.44
0.416
0.39
0.364
0.337
0.308
0.278
0.247
0.216
0.183]';
plot(Q, HE, 'b', 'LineWidth',2); %Pumpkurva
% Aproximation of the pump with a 2.order polynomial
vals_pump = polyfit(Q,HE,2);
fun_pump = polyval(vals_pump,Q);
plot(Q,fun_pump,'sb')
% Aproximation of the pump with a 2.order polynomial
res_system = polyfit(Q,H,2);
fun_system = polyval(res_system,Q);
plot(Q,fun_system,'sk')
% solve with fzero
intersection_point = fzero(@(Q) polyval(vals_pump,Q) - polyval(res_system,Q),2);
scatter(intersection_point, polyval(vals_pump,intersection_point),'or','filled')
hold off
fprintf('The intersection point is: Q = %1.5f with H = %.5f units.\n'...
,intersection_point, polyval(vals_pump,intersection_point))
With the resulting plot:
Best regards
Stephan

Community Treasure Hunt

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

Start Hunting!