How to integrate using only symbolic variables, or variables in general?

2 ビュー (過去 30 日間)
Grant Griffin
Grant Griffin 2017 年 4 月 16 日
回答済み: Chaitral Date 2017 年 4 月 24 日
syms A f0 t0 f0
ft = piecewise(0<=t<=t0/2,A.*sin(2.*pi.*f0.*t),t0/2<=t<=t0, 0);
a0 = 1/t0.*int(A.*sin(2.*pi.*f0.*t),t,0,t0./2)
simplify(a0)
pretty(a0)
I am trying to integrate the function A*sin(2*pi*f0*t) from 0 to t0/2, however whenever I run my script, the output is clearly the incorrect evaluation seen below:
/ pi f0 t0 \2
A sin| -------- |
\ 2 /
------------------
f0 t0 pi
This is for calculating the fourier coefficient a0, using basic integration for a half-wave rectified sine wave, and the expected result is A/pi.
Any suggestions that could point me in the right direction would be greatly appreciated!

回答 (1 件)

Chaitral Date
Chaitral Date 2017 年 4 月 24 日
I executed the above code and observed the same output. The method which you are using is the appropriate way to find out definite integral of a symbolic expression. Hence the output which we are observing is correct.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by