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 vue (au cours des 30 derniers jours)
Rahul Joshi
Rahul Joshi le 15 Sep 2021
Commenté : Alan Stevens le 15 Sep 2021
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 commentaires

Connectez-vous pour commenter.

Réponses (1)

Alan Stevens
Alan Stevens le 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).
  2 commentaires
Rahul Joshi
Rahul Joshi le 15 Sep 2021
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 le 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')

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by