Find the intersection of two lines with multiple intersections.

2 visualizzazioni (ultimi 30 giorni)
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");

Risposte (2)

KSSV
KSSV il 2 Set 2022
Modificato: KSSV il 2 Set 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')

Bruno Luong
Bruno Luong il 2 Set 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,'--'); 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')

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by