Numerical integral where the bounds change with each evaluation

3 ビュー (過去 30 日間)
L'O.G.
L'O.G. 2023 年 5 月 16 日
コメント済み: Walter Roberson 2023 年 5 月 16 日
I'm trying to take the following integral:
I tried this symbolically, but I think that was throwing me off. I am attaching some numerical data for the function A(t) and the time vector. How would you do this numerically? I imagine it would be something like the following, but I can't quite get it to work.
omega = logspace(-1,1,1000);
fun = @(t,omega) A*sin(omega*t);
for i = 1:1000;
w=omega(i);
f(i) = integral(@(t) fun(t,w),0,2*pi/w);
end
  3 件のコメント
FannoFlow
FannoFlow 2023 年 5 月 16 日
Does A(t) have a special meaning in this context?
Walter Roberson
Walter Roberson 2023 年 5 月 16 日
A(t) just means that A is a function of t.
It is the expression for some kind of tranform of A(t), but I am not sure what the name of this transform is.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 16 日
A = rand
A = 0.8252
omega = logspace(-1,1,1000);
fun = @(t,omega) A*sin(omega*t);
for i = 1:1000;
w=omega(i);
f(i) = integral(@(t) fun(t,w),0,2*pi/w);
end
plot(omega, f)
All of the values are within round-off error of 0.
However... there is a difference between what your mathematical expression shows here, compared to the integral you were calculating there and here.
In previous discussion, A was a constant. In the expression here, A is a function of t. That makes a big difference.
For example,
A = @(t) t.^2 - t + 1;
omega = logspace(-1,1,1000);
fun = @(t,omega) A(t).*sin(omega*t);
for i = 1:1000;
w=omega(i);
FUN = @(t) fun(t,w);
f(i) = integral(FUN,0,2*pi/w);
end
plot(omega, f)
syms t Omega
A = @(t) t.^2 - t + 1;
omega = logspace(-1,1,1000);
fun = @(t,omega) A(t).*sin(omega*t);
F = int(fun(t,Omega), t, 0, 2*pi/Omega)
F = 
f = subs(F, Omega, omega);
plot(omega, f)
  4 件のコメント
Walter Roberson
Walter Roberson 2023 年 5 月 16 日
"how would you modify it to use a vector of type double which is also a function of t"
Vectors are not functions.
If you have the value of A(t) sampled at particular t, then calculate A(t).*sin(omega*t) at those t, and use trapz() or similar to do numeric integration, making sure to pass in the appropriate t values to trapz()
Walter Roberson
Walter Roberson 2023 年 5 月 16 日
Hmmm, first, could you confirm for me that you want omega to range from -1 to 1, and the bounds of integration is 0 to 2*pi/omega -- and since omega ranges from -1 to +1, that means that for negative omega you want negative upper bound, and you want to go right through to infinite upper bound as omega passes through 0 ?

サインインしてコメントする。

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by