Calculating energy and power of a signal
94 ビュー (過去 30 日間)
古いコメントを表示
geometry geometry
2018 年 3 月 18 日
コメント済み: Walter Roberson
2021 年 10 月 24 日
I tried this code to calculate energy and power of the input function f(x). but I get error. how can I fix it?
syms x y z energy pow t;
f=input('enter function: ','s');
f = symfun(eval(f), x);
f=f*conj(f);
f = str2func(['@(x)' vectorize(f)]);
z(t)=integral(y,-t,t);
energy=limit(z(t),t=infinity);
pow=limit(z/t,t=infinity)
0 件のコメント
採用された回答
Walter Roberson
2018 年 3 月 18 日
I suggest that instead of using
f = str2func(['@(x)' vectorize(f)]);
that you use
f = matlabFunction(f);
However, you could just comment out all of your handling of f, as you never use f after you make it into a function handle.
You have
z(t)=integral(y,-t,t);
At this point your y is a symbolic variable. integral() cannot be applied to symbolic variables: you would need to use int(y, -t, t) -- which is a value you can easily predict will be 0, since the integral of y with respect to y over y = a to y = b is 1/2 b^2 - 1/2 a^2 and with a = -t and b = -t that is going to be 1/2 t^2 - 1/2 (-t)^2 which is going to be 0.
2 件のコメント
その他の回答 (1 件)
SHREEVARSHINI R
2021 年 10 月 24 日
write a matlab program to find the energy and power of the signal x(t) = 10sin(10*pi*t).
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!