How to find a circle segment within a matlab function

조회 수: 3 (최근 30일)
Mikael
Mikael 2023년 2월 22일
답변: Image Analyst 2023년 2월 23일
I need to create a function that will find the length of the arc of a circle which is 2 times the length of the segment AB that is reuniting both ends of the arc. Here is my function but I know that within the loop «for» there is a mistake but I can't see where.
The function «func» is where my angle in rad is multiplied by the radius divided by 2 (i suppose this is the good function considering the informations mentionned before).
function [rep]=Arcb(theta)
Ea=1.0;
Er=0.00001;
itermax=25;
i=0;
r=1;
iflag=0;
for i=1:itermax
func=(theta)*r/2;
dfunc=r/2;
theta2=theta-(func/dfunc);
Ea=abs((theta2-theta)/theta);
if Ea<=Er
rep=theta2;
fprintf('La solution après %d itérations est %5.2\n',i,rep);
iflag=1;
break
else
rep=theta;
end
end
end
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 2월 23일
Please format your code properly.
Regardless of the (finite) value of theta, theta2 will always be zero -
func=(theta)*r/2;
dfunc=r/2;
theta2=theta-(func/dfunc);

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2023년 2월 23일
A diagram sure would have helped. Without it about all I can suggest is the FAQ:
or the attached paper.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by