How can i get value of alpha using trail and error
Show older comments
I have equation CL = 2*(sin(alpha))^2 * cos(alpha)
and value of CL = -0.525
I need value of alpha using trail and error running for loop in MATLAB but not getting, Please help me with possible soution
3 Comments
Scott MacKenzie
on 22 Apr 2021
Edited: Scott MacKenzie
on 22 Apr 2021
I'm not going to put together a solution, but here's some code to get you thinking about how to do this.
>> alpha = linspace(0,2*pi);
>> cl = 2*sin(alpha).^2.*cos(alpha);
>> lower = cl < -0.525;
>> idx = find(lower, 1);
>> clBracket = [cl(idx-1) cl(idx)]
clBracket =
-0.4951 -0.58416
>> alphaBracket = [alpha(idx-1) alpha(idx)]
alphaBracket =
1.8405 1.904
You can see above that the CL value you specified is between the two CL "bracket" values. And the corresponding alphas are also shown. So, at this stage we know that alpha is between 1.8405 radians and 1.904 radians. The mean of these two values is a first-level approximation of alpha. You could follow this up with additional code that gets you closer to alpha. For example, you can repeat the statements above, except beginning with
alpha = linspace(alphaBracket(1), alphaBracket(2))
This will get you much tigher bracket values, and get you closer to an acceptable solution. Are you with me?
You can put all this in a loop and compute
abs(alphaBracket(1) - alphaBracket(2))
as the last step. When this value is below some acceptable value, usually called episilon, you're done.
Good luck.
Priyank Goel
on 22 Apr 2021
If your goal is simply to get smooth curves through those points, you can just do spline interpolation:
x1 = [3.34, 3.93, 3.65, 2.50, 1];
x2 = [0.19, 0.36, 0.64, 0.84, 1];
y = [0.10, 0.20, 0.40, 0.60, 1];
yf=linspace(0.1,1,50);
x1f=interp1(y,x1,yf,'spline');
x2f=interp1(y,x2,yf,'spline');
% draw the original coarse curves
plot(y,x1,':'); hold on; grid on
plot(y,x2,':');
% draw the smoothed curves
plot(yf,x1f);
plot(yf,x2f);

Feel free to swap axes if you want the plot facing the other way
If you find the endpoint behavior of 'spline' to be too outrageous, try 'pchip' or 'makima':

Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!