fprintf for total sum

6 ビュー (過去 30 日間)
fushen Lee
fushen Lee 2021 年 2 月 7 日
コメント済み: fushen Lee 2021 年 2 月 7 日
N = input("Enter value for N:");
total = 0;
for index=1:N
total = total +(1/index+1/((index+2)*(index+3))) ;
end
fprintf(
Question how to it fprintf the answer, i able to use display but i have not idea how to made it on fprintf?
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 7 日
Rewriting in terms of index looks better.
fushen Lee
fushen Lee 2021 年 2 月 7 日
Hi Roberson,
Thank you for you advice i was able to get the result after rewrite.

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

採用された回答

Ive J
Ive J 2021 年 2 月 7 日
doc fprintf
An example for a floating point number:
X = 2.345674;
fprintf('My number is %.2f\n', X)
My number is 2.35
  1 件のコメント
fushen Lee
fushen Lee 2021 年 2 月 7 日
Thank you so much J.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by