How to do write the codes for this summation problem?

How to write the codes for this.
where
n=5
T=[0.56, 0.23, 1.58, 2.69, 1.1]
Thank you.

回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 10 月 22 日

0 投票

Having defined n and T then
B = 1./(log(T) - mean(log(T)));
Note that in Matlab, log is log to base e.

10 件のコメント

Alan Stevens
Alan Stevens 2020 年 10 月 22 日
In fact, you don't need to define n explicitly!
MD. Rokibujjaman sovon
MD. Rokibujjaman sovon 2020 年 10 月 22 日
Thanks.
If there is not a mean, then how should i write it? For example,
T=[0.56, 0.23, 1.58, 2.69, 1.1]
Alan Stevens
Alan Stevens 2020 年 10 月 22 日
In that case use
sum(log(T))
for the summation part.
Type help sum in the command window for more detail.
MD Rokibujjaman Sabuj
MD Rokibujjaman Sabuj 2020 年 10 月 22 日
I tried to check there at first. But i don’t understand how to define the i. Can you kindly write the full codings? It will help me to understand.
Alan Stevens
Alan Stevens 2020 年 10 月 22 日
You don't need to do the i, MATLAB automatically adds up all the terms.
MD Rokibujjaman Sabuj
MD Rokibujjaman Sabuj 2020 年 10 月 22 日
編集済み: MD Rokibujjaman Sabuj 2020 年 10 月 22 日
I tired to use B = 1./(log(T)-sum(log(T)))
But it’s not running.
Alan Stevens
Alan Stevens 2020 年 10 月 22 日
Upload the exact code that you used (use the code button in the menu ribbon).
MD. Rokibujjaman sovon
MD. Rokibujjaman sovon 2020 年 10 月 22 日
編集済み: MD. Rokibujjaman sovon 2020 年 10 月 22 日
I tired to use
T=[0.56; 0.23; 1.58; 2.69; 1.1]
B = 1./(log(T) - sum(log(T)));
Alan Stevens
Alan Stevens 2020 年 10 月 22 日
It works for me:
>> T=[0.56; 0.23; 1.58; 2.69; 1.1];
B = 1./(log(T) - sum(log(T)))
B =
-13.7741
-1.0390
1.0367
0.6681
1.6597
Look in the Workspace window to see the values, or remove the semicolon to see the values in the command window.
MD Rokibujjaman Sabuj
MD Rokibujjaman Sabuj 2020 年 10 月 22 日
Its working now. Thanks.

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

カテゴリ

質問済み:

2020 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by