フィルターのクリア

How to write a code for iteration?

2 ビュー (過去 30 日間)
HAKAN KORKMAZ
HAKAN KORKMAZ 2020 年 5 月 7 日
回答済み: Niharika Arora 2020 年 5 月 13 日
Hi,can ı run this equation with iteration?
first value ts = 10 and last value ts is under the error tolarence.Error torance is 0.1E-7
  1 件のコメント
Rik
Rik 2020 年 5 月 7 日
What do you mean with iteration in this case? Have a read here and here. It will greatly improve your chances of getting an answer.

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

回答 (1 件)

Niharika Arora
Niharika Arora 2020 年 5 月 13 日
You want to get the value of Ts for which the equation in the problem is equated to be true, with the tolerance of 100 micro unit.
There are primarily two ways to solve an equation of such kind:
  1. Analytically [Computationally Expensive]
  2. Iteratively
Given the initial value of Ts, I believe you want an iterative solution.
Before diving into the solution, let's see the plot of different Ts values vs the equation value:
The above plot is for the first 1000 values of Ts.
From the plot above, it is quite clear that the value resides in (200,400)
Knowing upper and lower bound helps in improving accuracy with less computation.
You can now try the following approach:
start=200;
end1=400;
finAB=0;
target=800;
tole=10^-8;
while(abs(finAB-target)>10^-8)
ts=(start+end1)/2;
sumA = 12*(ts-293);
sumB = 0.8*5.67*10^-8*(ts^4);
finAB=sumA+sumB;
if(finAB<target)
start=ts;
else
end1=ts;
end
disp(append(num2str(ts)," : ",num2str(finAB)));
end
The method used is called, binary search.

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by