Can i please get help with this question? I am new to MATLAB and do not know how to go about solving this in MATLAB, maybe i would be able to solve subsequest problems when i see the steps to this question. Thanks.

4 件のコメント

Dyuman Joshi
Dyuman Joshi 2021 年 5 月 15 日
How would you solve that question with pen and paper? Do you any knowledge of programming (irrelevant of the programming language)?
Chijioke  Nkwocha
Chijioke Nkwocha 2021 年 5 月 15 日
Solving with pen and paper, i have to, then i will input value for to for ti in the equation t(i+1) to get t1 and i will keep doing this until i get to t25. As i compute the above, i will substitute the values for t0 to t25 to get pi.
I do not have knowledge of programming, just trying to learn. Writing codes for iteration has been a challenge.
Dyuman Joshi
Dyuman Joshi 2021 年 5 月 15 日
Fair enough, I'll give you an outline of the code so you can work with it. In case you have any queries, do mention.
Chijioke  Nkwocha
Chijioke Nkwocha 2021 年 5 月 15 日
I was able to come up with a code for the aforementioned problem, but i doubt it is right. Any idea to make it better?

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

 採用された回答

Dyuman Joshi
Dyuman Joshi 2021 年 5 月 15 日
編集済み: Dyuman Joshi 2021 年 5 月 15 日

1 投票

In MATLAB, indexing start with 1 and not 0 (as it does in some programming languages).
%defining the initial values
t0 = 1/sqrt(3);
t = (sqrt(t0^2+1)-1)/t0;
pi_approx = (sqrt(t^2+1)-1)/t;
for i=1:24
t(i+1) = (sqrt(t(i)^2+1)-1)/t(i);
pi_approx(i+1) = 6*2^i*t(i+1);
end
%converting to table
y=array2table([t;pi_approx]', 'VariableNames',{'t','pi_approx'});

5 件のコメント

Chijioke  Nkwocha
Chijioke Nkwocha 2021 年 5 月 15 日
In the code above, the "for loop" calculates starting from t2, meanwhile, t1 has not been calculated previously.
Dyuman Joshi
Dyuman Joshi 2021 年 5 月 15 日
Do you want t1 to be calculated exclusively? If so, I can modify the code.
The code I have written calculates the corresponding value but it is not allocated to t1, because I treated t0 as t1.
(Reason - "In MATLAB, indexing start with 1 and not 0")
Chijioke  Nkwocha
Chijioke Nkwocha 2021 年 5 月 15 日
Yes, t1 has to be calculated and the corresponding pi also.
Dyuman Joshi
Dyuman Joshi 2021 年 5 月 15 日
I have edited my answer, check it.
Chijioke  Nkwocha
Chijioke Nkwocha 2021 年 5 月 15 日
Thanks.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

リリース

R2021a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by