How do I convert this integral equation to matlab code?

1 visualización (últimos 30 días)
John Doe
John Doe el 30 de Mzo. de 2015
Respondida: Torsten el 30 de Mzo. de 2015
I'm trying to write a matlab program for a Lock-in Amplifier, based on this equation:
where Fref is the frequency you're trying to extract, t the current time sample, T the total time, Fin the input signal and phi is the phase. Reference: http://en.wikipedia.org/wiki/Lock-in_amplifier
When it comes to the integration I'm stuck. My phase is 0, my time is 4.8828 seconds incrementing in 0.002 second steps per signal sample.
sigRef = 25;
mult = 2*pi*sigRef;
t=[0:1/512:4.8828];
Uin = trialDataL; % same length as t
fun = @(x) sin(mult*t(x)*Uin(x));
q = integral(fun,1,2)
"Integral" doesn't like using x as an index instead of a numeric value, but I don't know how to get t and Uin to both change samples at the same time.

Respuesta aceptada

Torsten
Torsten el 30 de Mzo. de 2015
Use trapz instead of integral.
Best wishes
Torsten.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by