1 view (last 30 days)

Show older comments

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.

Alan Stevens
on 15 Sep 2021

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).

Alan Stevens
on 15 Sep 2021

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')

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

Start Hunting!