to plot alpha(a) vs diameter(D) in the given problem. where A = l*sin(b), B = l*cos(b), C = ( h + 0.5*D )*sin (b) − 0.5*D*tan(b) and E = ( h + 0.5*D)*cos(b) − 0.5*D.

조회 수: 3 (최근 30일)
Given equation is A*sin(a)*cos(a) + B*sin(a)*sin(a) − C*cos(a) − E*sin(a) = 0 Also l = 89in., h = 49in. and b= 11.5(angle in degree).
we have to plot alpha(a) vs Diameter(D) using Newton's method where D varies from 30 - 100 inches with a step of 10 inch. plz reply soon.
  댓글 수: 4

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

답변 (1개)

Alan Stevens
Alan Stevens 2021년 9월 15일
Try replacing D within the j-loop by D(j). Also add something like alpha(j) = a after the end of the i-loop (but inside the j-loop). Then you can plot D vs alpha.
I think you will need to increase your value of maxIter to get a converged solution.
You might also think of using a while loop, instead of the i-loop, with an error calculation in order to compare the error to your tola value (which is currently unused).
  댓글 수: 2
Rahul Joshi
Rahul Joshi 2021년 9월 15일
Thank you for the help, these all things I did with some other modification but I couldnt get rid of the error value. Its not coming below tola value. Can u suggest any point?
Alan Stevens
Alan Stevens 2021년 9월 15일
How about:
%% initial conditions
l = 89;
h = 49;
b1 = 11.5;
D = 30:10:100;
a = 33;
maxIter = 1000;
tola = 1e-6;
err = 1;
%% define function
for j = 1:1:8
A = l*sind(b1);
B = l*cosd(b1);
C = ((h+0.5*D(j))*sind(b1)) - (0.5*D(j)*tand(b1));
E = ((h+0.5*D(j))*cosd(b1)) - (0.5*D(j));
its = 0;
err = 1;
while err>tola && its<maxIter
its = its+1;
aold = a;
f = (A*sind(a)*cosd(a) + B*sind(a)*sind(a) - C*cosd(a) - E*sind(a));
df = (A*cosd(2*a) + B*sind(2*a) + C*sind(a) - E*cosd(a));
a = a - f/df;
err = abs(a - aold);
end
if its==maxIter, disp(j), end
alpha(j) = a;
end
plot(D,alpha),grid
xlabel('D'), ylabel('alpha')

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by