Integration in Matlab from negative to positive infinity

134 ビュー (過去 30 日間)
Lukasz
Lukasz 2014 年 8 月 10 日
編集済み: Onyeka Okwundu 2018 年 9 月 14 日
Hi,
I tried using this syntax:
EDU>> syms x
EDU>> syms a
EDU>> syms L
EDU>> int(exp(-L*(x-a)^2), x = -infinity..infinity)
to evaluate an integral seen inside the parentheses over x, where L and a are just constants. However error showed up saying: | "Error: The expression to the left of the equals sign is not a valid target for an assignment."
Am I missing something? Also is Matlab a good tool for somebody working in physics/applied math who need to evaluate a lot of integrals? Would you recommend anything else more?
Thanks for all replies.

採用された回答

Yu Jiang
Yu Jiang 2014 年 8 月 11 日
編集済み: Yu Jiang 2014 年 8 月 11 日
Hi Lukasz
I think Roger is right, and the equal sign is not necessary.
The link you provided is only for MUPAD (Link) , which is a symbolic computation GUI in MATLAB. The syntax in MUPAD may not be applicable to MATLAB command window.
So, I suggest you change the last line to
>> int(exp(-L*(x-a)^2), 'x', -inf, inf)
MATLAB is indeed very suitable for physics/applied math where integrals need to be evaluated.
If you would like to perform pure symbolic computations, you may type MUPAD in MATLAB command line and do it from there. You may also do symbolic computations in the MATLAB command line, but be careful about the syntax difference between MATLAB scripts and MUPAD.
If you prefer numerical computations, you may want to use numerical integration function such as trapz (Documentation) and integral (Documentation) .
-Yu
  1 件のコメント
Onyeka Okwundu
Onyeka Okwundu 2018 年 9 月 14 日
編集済み: Onyeka Okwundu 2018 年 9 月 14 日
Thanks Jiang

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

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2014 年 8 月 10 日
The equal sign "=" is what matlab is complaining about. Read the documentation and you will see no equal sign in the required call on 'int'.
  1 件のコメント
Lukasz
Lukasz 2014 年 8 月 11 日
the equal sign is necessary. I wonder if it is the right way to write negative infinity in MATLAB?

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

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by