フィルターのクリア

Using a for loop to compute a Taylor series of sine?

3 ビュー (過去 30 日間)
Aaron Zorzi
Aaron Zorzi 2015 年 10 月 8 日
コメント済み: Esteban Gómez 2021 年 1 月 20 日
I understand while loops pretty well, but for loops always seem to throw me off. Can someone please help me? Thanks.
  2 件のコメント
James Tursa
James Tursa 2015 年 10 月 8 日
Please make an attempt and post your code, and then ask specific questions about it. Then we can comment on it and make suggestions.
Aaron Zorzi
Aaron Zorzi 2015 年 10 月 8 日
I would but I honestly have no clue where to begin. I understand how to ask for the input statements and make the fprintf statements, but that is all. I'm entirely lost.

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

採用された回答

Stalin Samuel
Stalin Samuel 2015 年 10 月 8 日
%%sample code
prompt = 'Enter angle value between 0 to 2pi? ';
x = input(prompt)
prompt = 'Enter the no of terms? ';
N = input(prompt)
ty = 0;
for i = 1:N
ty = ty +((-1)^(i))*((x^(2*i+1))/(factorial(2*i+1)));%your calculations
end
fprintf(['actual value ' num2str(ty)]) %display the results
  1 件のコメント
Esteban Gómez
Esteban Gómez 2021 年 1 月 20 日
It has a error. In the for loop is i=0:N.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by