How do I convert this integral equation to matlab code?
1 view (last 30 days)
Show older comments
I'm trying to write a matlab program for a Lock-in Amplifier, based on this equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148463/image.png)
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.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!