How to deduce the sine from N sample

Status
Not open for further replies.

dreamcatch16

Newbie level 4
Joined
Jan 23, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
51
Let's say that I have two sinusoidal signals that I want to deduce their amplitudes and the phase between them, I make N sampling for both signals,
how can I do it? knowing that both signals have the same frequency and we know that frequency.

thank you for your help.
 

Do you use Matlab? If so, consider an approach like this:

Code:
close all; clear all; clc;

% Define sampling times
dt = 0.001;
t = (0:dt:5).';

% Sine frequency
f = 3;

% Amplitudes
A1 = 2.6;
A2 = 0.7;

% Phases
phi1 = 0.4;
phi2 = -0.3;

% Sinusoids
x1 = A1*cos(2*pi*f*t + phi1);
x2 = A2*cos(2*pi*f*t + phi2);

% Estimated amplitudes
A1_est = sqrt(2*mean(x1.^2))
A2_est = sqrt(2*mean(x2.^2))

% Estimated phase difference
phase_diff = acos(x1.'*x2/(norm(x1)*norm(x2)))

I can discuss this approach in more detail, or offer an alternative approach which uses the FFT (Fast Fourier Transform).
 
Last edited:

Thank you for the reply,

Unfortunately I do not use MATLAB, I am going to code with C#,
For the FFT how can I do it?

Thank you for your help
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…