how can i write the code out for this 1-1/2+1/3-1/4+1/5-,.....

3 ビュー (過去 30 日間)
josh
josh 2020 年 8 月 2 日
コメント済み: Vladimir Sovkov 2020 年 8 月 2 日
how can i write the code out for this 1-1/2+1/3-1/4+1/5-,.....
  2 件のコメント
Vladimir Sovkov
Vladimir Sovkov 2020 年 8 月 2 日
S=log(2)
per isakson
per isakson 2020 年 8 月 2 日
Homework?

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

回答 (1 件)

KSSV
KSSV 2020 年 8 月 2 日
It is your Home work..you have to do it. Do the following.
  1. Read about for loop.
  2. Fix the value of n, to run a loop.
  3. You can decide the sign -, + by using mod.
  4. Intialize sum = 0, and add every time to loop (-1)^i*(1/j)
  4 件のコメント
Vladimir Sovkov
Vladimir Sovkov 2020 年 8 月 2 日
Two possibilities:
  1. It is a homework indeed. This case I do not want to explain anything--it is a responsibility of their professor, not me; besides, we do not know what the professor wants from them exactly.
  2. It is not a homework. They just encountered this problem in their current work but their matrhematical background is not good enough to find the best solution. This case my answer is the most useful.
Vladimir Sovkov
Vladimir Sovkov 2020 年 8 月 2 日
Moreover: one of the basic ideologies of Matlab is to avoid loops wherever possible. Hence, an advice to do it without a loop must be instructive for learning Matlab as well.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by