フィルターのクリア

Why is my code not working?

4 ビュー (過去 30 日間)
Michael Vaughan
Michael Vaughan 2020 年 9 月 26 日
回答済み: Jim Riggs 2020 年 9 月 26 日
I want the following script to calculate:
$$J_{(2,k)}(N)=\frac{1}{s-s^{-1}}{\sum_{j=\frac{-(N-1)}{2}}^{\frac{(N-1)}{2}}(s^{4j^2k+2jk}s^{4j+1}-s^{4r^2k-2jk}s^{4j-1})}$$
function f = CJ(N,k)
syms t
% compute the running sum
running_sum = 0;
for j = -(N-1)/2:(N-1)/2
running_sum = running_sum + t^(4*j^2*k+2*j*k)*t^(4*j+1)-t^(4*j^2*k-2*j*k)*t^(4*j-1);
end
% final value
f = (1/(t-t^(-1))*running_sum
end
Here is what happens when I try to run the program:
>> CJ(3,2)
Error: File: CJ.m Line: 10 Column: 34
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
thanks for your help

回答 (1 件)

Jim Riggs
Jim Riggs 2020 年 9 月 26 日
Not entirely sure if this is the reference in the error message, but this line has unballanced parentheses:
f = (1/(t-t^(-1))*running_sum

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by