How can you find the x intercepts between two signals in Matlab

2 views (last 30 days)
Hello! So I am plotting two different signals in Matlab that have a few intercepts that I would like to find. How can I have Matlab find and spit out these values for me? I tried find (faa1 == faa2) but it returned nothing. Here is my code:
if true
aa = 0:.0001:4*pi;
faa1 = ((12.*sin(aa))./aa) + cos(aa);
faa2 = cos(aa);
plot(aa,faa1), grid on
hold
plot(aa,faa2)
end

Answers (1)

Star Strider
Star Strider on 20 Sep 2015
See if this does what you want:
aa = 0:.0001:4*pi;
faa1 = ((12.*sin(aa))./aa) + cos(aa);
faa2 = cos(aa);
faad = faa1 - faa2; % Subtract Functions
shiftmult = faad.*circshift(faad, [0 -1]); % Detect Zero-Crossings
xzc = find(shiftmult <= 0); % Find Incides Of Zero-Crossings
xint = aa(xzc) % X-Intercepts
plot(aa,faa1), grid on
hold on
plot(aa,faa2)
plot(aa(xzc), faa2(xzc), 'bp') % Plot Intersections
hold off
xint =
3.1415 6.2831 9.4247

Community Treasure Hunt

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

Start Hunting!