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.

1 次查看(过去 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