Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB code The lift force L and the drag force D for a simple airfoil a

ID: 3874105 • Letter: W

Question

Write a MATLAB code

The lift force L and the drag force D for a simple airfoil are correlated by

L = A sin( D + B ) exp( 0.01 D ),

where A and B are parameters.

Develop a MATLAB function that for input values of A and B

1. Sets an anonymous function LofD that returns L given D.

2. Generates an equally spaced test distribution Ddistr of 100 values of D between 0 and 3

3. Finds the maximum value of L ( Lmax ) and the corresponding value of D , ( D_Lmax )

4. Returns in order LofD , Ddistr, Lmax , D_Lmax

CODE:

function [LofD, Ddistr, Lmax, D_Lmax] = Problem_4
% Input
% A: Lift Force Parameter
% B: Lift Force Parameter
%
% Output
% LofD: Anonymous function handle
% Ddistr: Test distribution of drag values
% Lmax: Maximum lift force
% D_Lmax: Drag force for maximum lift

% write your function below (replacing the existing code)
LofD= 0;
Ddistr=0;
Lmax=0;
D_Lmax=0;

end

Explanation / Answer

Given below is the completed code for the function. I have retained the name of the function as Problem_4. So place the code for the function in a file named Problem_4.m and then use it. Hope it helped. If it did, please don't forget to rate the answer. Thank you very much.

function [LofD, Ddistr, Lmax, D_Lmax] = Problem_4(A, B)
% Input
% A: Lift Force Parameter
% B: Lift Force Parameter
%
% Output
% LofD: Anonymous function handle
% Ddistr: Test distribution of drag values
% Lmax: Maximum lift force
% D_Lmax: Drag force for maximum lift
% write your function below (replacing the existing code)

LofD= @(D) A * sin( D + B ) .* exp( 0.01 * D ); %Anonymous function
h = 3.0 / 99; %calculate the step length needed for generating 100 values
Ddistr= 0: h : 3.0; %distribution of D values
L = LofD(Ddistr); %corresponding values of L
[Lmax, index]= max(L); %find the max of L and its corresponding index
D_Lmax=Ddistr(index); %value of D for the index of LMax
end

==============

You can use it by typing

[a, b, c, d] = Problem_4(3,5)

output

> [a, b, c, d] = Problem_4(3,5)
a =

@(D) A * sin (D + B) .* exp (0.01 * D)

b =

Columns 1 through 7:

0.00000 0.03030 0.06061 0.09091 0.12121 0.15152 0.18182

Columns 8 through 14:

0.21212 0.24242 0.27273 0.30303 0.33333 0.36364 0.39394

Columns 15 through 21:

0.42424 0.45455 0.48485 0.51515 0.54545 0.57576 0.60606

Columns 22 through 28:

0.63636 0.66667 0.69697 0.72727 0.75758 0.78788 0.81818

Columns 29 through 35:

0.84848 0.87879 0.90909 0.93939 0.96970 1.00000 1.03030

Columns 36 through 42:

1.06061 1.09091 1.12121 1.15152 1.18182 1.21212 1.24242

Columns 43 through 49:

1.27273 1.30303 1.33333 1.36364 1.39394 1.42424 1.45455

Columns 50 through 56:

1.48485 1.51515 1.54545 1.57576 1.60606 1.63636 1.66667

Columns 57 through 63:

1.69697 1.72727 1.75758 1.78788 1.81818 1.84848 1.87879

Columns 64 through 70:

1.90909 1.93939 1.96970 2.00000 2.03030 2.06061 2.09091

Columns 71 through 77:

2.12121 2.15152 2.18182 2.21212 2.24242 2.27273 2.30303

Columns 78 through 84:

2.33333 2.36364 2.39394 2.42424 2.45455 2.48485 2.51515

Columns 85 through 91:

2.54545 2.57576 2.60606 2.63636 2.66667 2.69697 2.72727

Columns 92 through 98:

2.75758 2.78788 2.81818 2.84848 2.87879 2.90909 2.93939

Columns 99 and 100:

2.96970 3.00000

c = 3.0867
d = 2.8788

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote