フィルターのクリア

How to get numerical value from symbolic variables in matlab?

1 回表示 (過去 30 日間)
ABTJ
ABTJ 2019 年 3 月 25 日
回答済み: Walter Roberson 2019 年 3 月 25 日
I am studying energy and power signals in MATLAB from the book "Signals & systems laboratory with MATLAB". I am trying to implement the example code at top of page123
code is follow:
syms t T
x=heaviside(t)-heaviside(t-1);
d=int(abs(x)^2,t,-T,T);
Px=limit((1/(2*T))*d,T,inf)
Ex=limit(d,T,inf)
I am expecting a result in numeric form, as shown in book to be Px=0 and Ex=1, but when I run my code, I get the result as a big equation as follows:
Px=limit(int(abs(heaviside(t) - heaviside(t - 1))^2, t, -T, T)/T, T == Inf)/2
Ex=limit(int(abs(heaviside(t) - heaviside(t - 1))^2, t, -T, T), T == Inf, Real)
How can I get a numeric result?

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 25 日
MATLAB is having trouble with the abs(x)^2 layer.
We as human(-ish)es can analyze and see that in context, the input arguments are always going to be real valued. With real-valued arguments, abs(x)^2 is going to be the same as x^2 . If you change to x^2 instead of abs(x)^2 then you will get a definite result.

その他の回答 (0 件)

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by