How to find coordinates of intersecting line?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Kalasagarreddi Kottakota
el 20 de Nov. de 2022
Hi, I have plot which is shown below and there is black (dashed) vertical line in x axis at 3. I need to find the coordinates of intersection between black line and red curve.
clear all; close all;
fs= 8192*2; % sampling frequency
dt = 1/fs; % sample time
T=5; % duration of the signal
Nt = T*fs; % total number of samples
t = 0:dt:T-dt; % time vector
% Source definition
f0 = 1; % frequency at time t = 0s
f1 = 5; % freqeuncy at time t = T
%-------------------------------------------------------
beta = (f1-f0)/T; % beta
finst = f0+beta*t.'; % instantaneous frequency
phi = 2*pi*cumsum(finst)*dt;
figure()
plot(wrapTo2Pi(phi),t,'r');
hold on
xline(3,'--k')
xlabel('phase')
ylabel('s')
0 comentarios
Respuesta aceptada
Matt J
el 20 de Nov. de 2022
Editada: Matt J
el 20 de Nov. de 2022
fs= 8192*2; % sampling frequency
dt = 1/fs; % sample time
T=5; % duration of the signal
Nt = T*fs; % total number of samples
t = 0:dt:T-dt; % time vector
% Source definition
f0 = 1; % frequency at time t = 0s
f1 = 5; % freqeuncy at time t = T
%-------------------------------------------------------
beta = (f1-f0)/T; % beta
finst = f0+beta*t.'; % instantaneous frequency
phi = 2*pi*cumsum(finst)*dt;
figure()
plot(wrapTo2Pi(phi),t,'r');
hold on
xline(3,'--k')
xlabel('phase')
ylabel('s')
hold off
z=wrapTo2Pi(phi(:)).';
n=nnz(diff(z)<-pi);
tc=interp1(phi,t,3+2*pi*(0:n) );
pc=0*tc+3;
hold on; plot(pc,tc,'xb'); hold off
0 comentarios
Más respuestas (1)
Torsten
el 20 de Nov. de 2022
fs= 8192*2; % sampling frequency
dt = 1/fs; % sample time
T=5; % duration of the signal
Nt = T*fs; % total number of samples
t = 0:dt:T-dt; % time vector
% Source definition
f0 = 1; % frequency at time t = 0s
f1 = 5; % freqeuncy at time t = T
%-------------------------------------------------------
beta = (f1-f0)/T; % beta
finst = f0+beta*t.'; % instantaneous frequency
phi = 2*pi*cumsum(finst)*dt;
phase = wrapTo2Pi(phi);
n = numel(phase);
v = (phase(1:n-1)-3).*(phase(2:n)-3);
idx = v <= 0;
coordinates = t(idx);
figure()
plot(phase,t,'r');
hold on
xline(3,'--k')
xlabel('phase')
ylabel('s')
plot(3*ones(size(coordinates)),coordinates,'o')
hold off
2 comentarios
Matt J
el 20 de Nov. de 2022
I wonder if the jump discontinuity lines are to be considered part of the curve.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!