How to get numerical value from symbolic variables in matlab?
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!