Symbolic Calculation to Numeric value for limit of an integral
1 view (last 30 days)
Show older comments
Hi, I've got a problem trying to evaluate numerically a symbolic expression, which by the way should represent the power of a signal.
I run my script and as a result I get the symbolic formula I am trying to solve; when I apply "vpa" I obtain the same result, instead with "eval" or "feval" there will occur errors.
Here the functions I use, potenza and fmodulsquared:
function [y] = potenza (signal)
hMod = @fmodulsquared;
hModsign = @(t) hMod(signal(t));
syms D;
resultIntegral = (int( hModsign, -D/2 , +D/2 ))./D;
y = limit(resultIntegral,D,+Inf);
end
function z = fmodulsquared(x)
z = abs(x).^2 ;
end
Now, running this script -which I use to test the function potenza - :
signal = @(t) -3*(sin((t-5/2)/3));
power = potenza(signal);
fprintf("La potenza del segnale è: %s \n", power);
vpa(power)
I get :
La potenza del segnale è: limit(int(9*abs(sin(t/3 - 5/6))^2, t, -D/2, D/2)/D, D, Inf)
ans =
limit(int(9*abs(sin(t/3 - 5/6))^2, t, -D/2, D/2)/D, D, Inf)
using eval instead of vpa I get:
Error using evalin
Unrecognized function or variable 't'.
Error in sym/eval (line 14)
s =
evalin('caller',vectorize(map2mat(char(x))));
2 Comments
Accepted Answer
darova
on 1 Apr 2020
Look at your signal
t = linspace(0,100);
signal = @(t) -3*(sin((t-5/2)/3));
area(t,signal(t))
axis equal
It never ends! Integral is area under the curve
3 Comments
More Answers (0)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!