Getting error using syms to implement power formula

1 回表示 (過去 30 日間)
Giggs B.
Giggs B. 2021 年 6 月 28 日
コメント済み: Giggs B. 2021 年 6 月 30 日
Hi,
I am trying to implement the power formula which is in the attached image.
I have written my code like this:
.
.
syms N; %Power formula
syms fs_sym;
fs_sym=sym(fs);
N=fs_sym*3;
syms x_hsym;
syms n;
syms f1;
syms f;
syms Power;
x_hsym=sym(x_h);
%f= (1/(2*N+1))*symsum((abs(x_h(n))),n,-N,N);
f1=symsum((abs(x_hsym(n))),n,-N,N);
f= (1/(2*N+1))*f1;
Power=limit(f,N,inf);
This code is in continuation with some more code. So x_h along with other variabes were double, so I changed all of them to symbolic variales. But I am getting error:
Error using sym/subsindex (line 814)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and
function body must be sym expression.
Error in sym/subsref (line 859)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in BestAlgorithmDetection (line 97)
f1=symsum((abs(x_hsym(n))),n,-N,N);
I tried a couple of things, but cannot fix it. Can anyone help or provide a better way to implement the avove formula?

採用された回答

Alan Stevens
Alan Stevens 2021 年 6 月 28 日
Like this?
% Arbitrary values - replace with your own
fs = 1;
x_h = @(n) 1/(n+10)^2;
%Power formula
syms N fs_sym x_hsym n f Power;
fs_sym=sym(fs);
N=fs_sym*3;
f= (1/(2*N+1))*symsum((abs(x_h(n))),n,[-N,N]);
Power=limit(f,n,inf);
disp(Power)
  17 件のコメント
Paul
Paul 2021 年 6 月 30 日
I should have been more precise. The independent variable n is defined as -inf < n < inf. But I think you know what I meant.
Giggs B.
Giggs B. 2021 年 6 月 30 日
@Paul yes, I got that. Thanks :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by