Find the intersection of two lines with multiple intersections.

Hi,
I am trying to find the intersection of these two lines and plot both. I have tried fzero() and fiind(), but they are both not working.
% Basic Variables
k_prime = 1000; np = .85; P = 750; rho = 1.225; S = 25; W = 1600*25; Cl_max = 1.5; k = .05;
Cdo = .025; Cd = Cdo + .05*(Cl_max^2); W_S = 1600; V = 0:200;
% Equations
Pa = k_prime * np * P;
Pr = (.5 * rho * S * Cdo * V.^3) + ((2*k*W^2)./(rho*S*V));
% Plotting
figure; ylim([0 10*10^5]); yline(Pa); hold on;
plot(V,Pr,'--'); hold on; legend("Available Power", "Required Power");

Réponses (2)

KSSV
KSSV le 2 Sep 2022
Modifié(e) : KSSV le 2 Sep 2022
% Basic Variables
k_prime = 1000; np = .85; P = 750; rho = 1.225; S = 25; W = 1600*25; Cl_max = 1.5; k = .05;
Cdo = .025; Cd = Cdo + .05*(Cl_max^2); W_S = 1600; V = 0:200;
% Equations
Pa = k_prime * np * P;
Pr = (.5 * rho * S * Cdo * V.^3) + ((2*k*W^2)./(rho*S*V));
% Plotting
figure;
ylim([0 10*10^5]);
yline(Pa); hold on;
plot(V,Pr,'--');
legend("Available Power", "Required Power");
% Find intersection
x = linspace(min(V),max(V),200) ;
y = Pa*ones(size(x)) ;
P = InterX([x;y],[V;Pr]) ;
plot(P(1,:),P(2,:),'*r')
% Basic Variables
k_prime = 1000; np = .85; P = 750; rho = 1.225; S = 25; W = 1600*25; Cl_max = 1.5; k = .05;
Cdo = .025; Cd = Cdo + .05*(Cl_max^2); W_S = 1600; V = 0:200;
% Equations
Pa = k_prime * np * P;
Pr = (.5 * rho * S * Cdo * V.^3) + ((2*k*W^2)./(rho*S*V));
% Plotting
figure; ylim([0 10*10^5]); yline(Pa); hold on;
plot(V,Pr,'--'); hold on; legend("Available Power", "Required Power");
fun=@(V)(.5 * rho * S * Cdo * V.^3) + ((2*k*W^2)./(rho*S*V))-Pa;
V1=fzero(fun,20)
V1 = 8.1980
V2=fzero(fun,120)
V2 = 115.6625
plot([V1 V2],[Pa Pa],'or')

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Produits

Version

R2022a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by