Solving a sum of series of exponential function with a sum of series of cosine function inside

11 ビュー (過去 30 日間)
Here is the equation I'm going to solve.
where epsilon is a variable.
I wrote the following code.
r = 1:(2^h)-1;
v = 1:h-1
T = exp(x*h/1000)+sum(exp((x/1000)*(cos(2*pi*r/(2^h))+cos(2*pi*r*(2^v)/(2^h)))));
I can run the code when h=2; however, when h becomes greater than or equal to 3, an error that input must be a scalar and a square matrix shows up.
Could anyone please help me on this error?
  3 件のコメント
Torsten
Torsten 2017 年 7 月 5 日
Is "epsilon" in your equation a given function ?
Is "e" in your equation the usual Euler-number ?
A closing round parenthesis is missing in your picture.
What does e{...} mean ? Does it mean exp(...) ?
Please clarify.
Best wishes
Torsten.
Cheung Ka Ho
Cheung Ka Ho 2017 年 7 月 5 日
epsilon is only a variable while e is the usual Euler-number. I mistakenly type it as e{...}. It should be e^{...}. Thank you for your help.

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

採用された回答

Torsten
Torsten 2017 年 7 月 5 日
編集済み: Torsten 2017 年 7 月 5 日
h=...;
epsilon=...;
r=1:2^h-1;
v=1:h-1;
result=sum(exp(epsilon*sum(cos(pi/2^(h-1)*(2.^v).'*r))));
Best wishes
Torsten.

その他の回答 (2 件)

Matthew Taliaferro
Matthew Taliaferro 2017 年 7 月 2 日
編集済み: Matthew Taliaferro 2017 年 7 月 3 日
You cannot raise things to a power unless they are scalar or square (like the warning said). If you want to square each element, the notation is a little different.
h = 1:10
h_square = h.^2 % as opposed to h^2, which won't work
You also cannot divide something element by element unless it is a scalar.
r = 1:10; h = 1:10;
r_over_h = r./(h.^2); % as opposed to r/(h^2), which won't do what you think it does
  1 件のコメント
Cheung Ka Ho
Cheung Ka Ho 2017 年 7 月 4 日
Thank you for your help. It solves the above error. However, another problem that inner matrix dimensions must agree comes out. How can I resolve this error?

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


mohammed alzubaidy
mohammed alzubaidy 2021 年 5 月 16 日

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by