Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to do for function in MATLAB be doing the pseudocode below ?

조회 수: 2 (최근 30일)
Mohammed AlQahtani
Mohammed AlQahtani 2022년 2월 9일
마감: Stephen23 2022년 2월 9일
  댓글 수: 3
DGM
DGM 2022년 2월 9일
Normally, you start by working out the parts that you can work out. Then once you discern that you cannot make more progress without consultation, you organize the sum of what you've accomplished so far and formulate a series of pointed questions which you yourself design to give you targeted insight into specific parts of the problem which you don't yet understand.
Then when you approach someone else for consultation, you communicate by demonstration that 1) you've made earnest effort, and 2) you communicate the current scope of your understanding.
Mohammed AlQahtani
Mohammed AlQahtani 2022년 2월 9일
clear
clc
a=1.9;
b=1.8;
N=17;
TOL=10^-5;
i=1;
f=@(x) 2*sin(x);
fa=f(a);
while i<=N
p=a+((b-a)/2);
fp=f(p);
if (fp==0)||((b-a)/2<TOL)
fprintf("Procedure compueted successfully with p=%.9f",p);
return
end
i=i+1;
if fa*fp > 0
a=p;
fa=fp;
else
b=p;
end
end
I couldn't do it by for loop

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by