Find Intersection between curves

In the intersection part
I tried many functions but still couldn't get the right value

Réponses (2)

KSSV
KSSV le 28 Juin 2022

0 votes

8 commentaires

Anfal AlShehhi
Anfal AlShehhi le 28 Juin 2022
I do have 2 functions only that vary with a range. Not helpful but thanks anyway
KSSV
KSSV le 28 Juin 2022
Why not helpful?
Anfal AlShehhi
Anfal AlShehhi le 28 Juin 2022
As my 2 curves functions have a range that changes i can't defined y1, x1, x2,y2
KSSV
KSSV le 28 Juin 2022
Why not?? Copy and paste your code here....image will not help us to help you.
clc; clear all;
% Defined values
atm=0.17 % km-1
xt=2.3; % target (x) in m
yt=2.3; % target (y) in m
p=50/100; % percent target
vis=23; %Visibility in km target
er=26; % LRF
dref=500; % LRF in m
pref=85/100; % LRF
vis2=23; % LRF Visbility
T=90/100; % LRF
sc=1; % LRF
% Range
x=0:0.01:10; % in km
A= exp(-2*atm.*x) % Attenuation func
B= ((pref/p)*((x.*x)*1000/dref*dref))*(((exp((-2*atm*dref/1000))*10^(-er/10)))/(T*sc)) % Sensi func
%Intersection point
f1 = @(x) exp(-2*atm.*x);
f2 = @(x)((pref/p)*((x.*x)*1000/dref*dref))*(((exp((-2*atm*dref/1000))*10^(-er/10)))/(T*sc));
f = @(x) f1(x) - f2(x);
xx = 0:0.01:10;a
t = f(xx) > 0;
% plotting
figure
plot(A,x.*1000,'-b')
hold on
plot(B/1000,x.*1000,'-r')
plot(x0,y0,'ro','MarkerFaceColor','g')
grid on
xlabel("Range in km")
ylabel("Distance in km")
title("Range Preformance")
legend('Atmospheric Attenuation','Sensitivity','Intersection')
hold off
KSSV
KSSV le 28 Juin 2022
You want intersection of what and what?
Anfal AlShehhi
Anfal AlShehhi le 28 Juin 2022
When plotting eqauation A & B there is an intersect point between the 2 curves. Am trying to figure this out.
clc; clear all;
% Defined values
atm=0.17 ; % km-1
xt=2.3; % target (x) in m
yt=2.3; % target (y) in m
p=50/100; % percent target
vis=23; %Visibility in km target
er=26; % LRF
dref=500; % LRF in m
pref=85/100; % LRF
vis2=23; % LRF Visbility
T=90/100; % LRF
sc=1; % LRF
% Range
x=0:0.01:10; % in km
A= exp(-2*atm.*x) ; % Attenuation func
B= ((pref/p)*((x.*x)*1000/dref*dref))*(((exp((-2*atm*dref/1000))*10^(-er/10)))/(T*sc)) ;% Sensi func
L1 = [x;A] ; L2 = [x;B] ;
P = InterX(L1,L2) ;

Connectez-vous pour commenter.

I think the script shared File Exchange works. However, if you want something mathematically simple to understand, you can try fzero(). The approach is similar to what you did previously.
atm = 0.17; % km-1
xt = 2.3; % target (x) in m
yt = 2.3; % target (y) in m
p = 50/100; % percent target
vis = 23; % Visibility in km target
er = 26; % LRF
dref = 500; % LRF in m
pref = 85/100; % LRF
vis2 = 23; % LRF Visbility
T = 90/100; % LRF
sc = 1; % LRF
% Range
x = 0:0.01:10; % in km
A = exp(-2*atm.*x); % Attenuation func
B = ((pref/p)*((x.*x)*1000/dref*dref))*(((exp((-2*atm*dref/1000))*10^(-er/10)))/(T*sc)); % Sensi func
% Plotting two curves initially
plot(x, A, x, B)
ylim([0 1])
% Finding the intersection point
f1 = @(x) exp(-2*atm.*x);
f2 = @(x) ((pref/p)*((x.*x)*1000/dref*dref))*(((exp((-2*atm*dref/1000))*10^(-er/10)))/(T*sc));
f = @(x) f1(x) - f2(x);
x0 = 0.5; % initial guess value (intersection is somewhere near x = 0.5)
xsol = fzero(f, x0)
xsol = 0.4621
ysol = f1(xsol)
ysol = 0.8546
% Markng the intersection point
plot(x, A, x, B), hold on
plot(xsol, ysol, 'mo', 'MarkerSize', 14), hold on
ylim([0 1])

Produits

Version

R2022a

Commenté :

le 28 Juin 2022

Community Treasure Hunt

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

Start Hunting!

Translated by