How do I convert this integral equation to matlab code?

3 ビュー (過去 30 日間)
John Doe
John Doe 2015 年 3 月 30 日
回答済み: Torsten 2015 年 3 月 30 日
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.

採用された回答

Torsten
Torsten 2015 年 3 月 30 日
Use trapz instead of integral.
Best wishes
Torsten.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by