How do I plot the intersections of two functions???
Show older comments
Hello,
I have been tasked with plotting two functions and having to find where the two intersect (F1 and F2).
Choose and define an appropriate time domain t to accommodate 8 relative maxima of s (t) for t> 0 and 8 relative maxima for t <0.
Put markers to emphasize the point of intersection between F1, F2 curve and print the results of those intersections. Calculate the lim s (t) for t-> 0 (0+ and 0-) analytically and compare this result to the Matlab curve
Thank you.
xmin=-5e-1; % min t...
xmax=5e-1; % max t...
xstep=0.001 ; % espacement t...
A=5;
b=20*2*pi;
x=xmin:xstep:xmax;
F1 = @(x) A*sin(b*x)./(b*x);
F2 = @(x) max(F1)/2 + 0*x;
fcndif = @(x) F1(x) - F2(x);
zx = fcndif(x) .* circshift(fcndif(x), [0 -1]);
gues = find(zx);
for k1 = 1:length(gues)
intsct(k1) = fzero(fcndif, x(gues(k1)));
end
figure(1)
a=plot(x, F1(x), x, F2(x))
set(a,'LineWidth',2)
set(gca,'FontSize',20)
xlabel('Axis [temps]')
ylabel('Axis [A]')
hold on
plot(intsct, F1(intsct), 'bp')
hold off
grid
Answers (1)
Ameer Hamza
on 3 Oct 2020
0 votes
See this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
1 Comment
triet tran
on 3 Oct 2020
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!