How to find coordinates of intersecting line?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kalasagarreddi Kottakota
le 20 Nov 2022
Modifié(e) : Torsten
le 20 Nov 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 commentaires
Réponse acceptée
Matt J
le 20 Nov 2022
Modifié(e) : Matt J
le 20 Nov 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 commentaires
Plus de réponses (1)
Torsten
le 20 Nov 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 commentaires
Matt J
le 20 Nov 2022
I wonder if the jump discontinuity lines are to be considered part of the curve.
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!