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

fid=fopen ( \' AOA vs CL . txt\' , fprintf (fid, \'alp, CLIn; \' w \') ; alp0 =-

ID: 3876673 • Letter: F

Question

fid=fopen ( ' AOA vs CL . txt' , fprintf (fid, 'alp, CLIn; ' w ') ; alp0 =-2 . 2; -AR=10; e = 0.95; a 5.190457428; AOA= zeros (-12, 1, 12); CL zeros (-12, 1, 12) ; = for i =-12: 1:20 AOA (i) = i; CL(1) = a* (AOA (1) -alp0); fprint f (fid,' %8.4f %8.4f ',AOA (1),CL (1)); end plot (AOA, CL) xlabel (Alpha AOA) ylabel (Coefficient of Lift') title"Aplha vs Coefficient of Lift') axis ([-12,20,-2,2]) fclose (fid); mmand Window >HW204b Undefined function or variable 'x'. Error in HW24b (line 14) for i = 1:x (AOA) >HW204b >HW204b Subscript indices must either be real positive integers or logicals. Error in HW24b (line 14) AOA (i) i; =

Explanation / Answer

Note that all indices in MATLAB start from 1, so here are two main issues with the code written by you:

1. declaration of AOA and CL: zeros(-12,1,12) is returning an empty matrix since the arguments of zeros() is supposed to have matrix dimensions. For details regarding syntax and working of zeros function, type 'help zeros' in command window

2. initialization of i in for loop: As already mentioned, indices start from 1 that is why AOA(i) is returning the error.

Please check below some suggestions and corrections suggested:

1.

% Since I was unable to understand what your AOA and CL are supposed to have, so based on understanding here are two options (a) Assuming that you want a matrix whose size equals to -12:1:20 i.e. 32 elements if you want AOA to be zero matrices of order 1*12, , uncomment this part
% AOA=zeros(1,32);
% CL=zeros(1,32);
% run_count=32; % no. of elements in AOA and CL

% (b) if you want AOA to be matrices of ones of order 1*12
AOA=-12*ones(1,12);
CL=-12*zeros(1,12);
run_count=12; % no. of elements in AOA and CL

2. The corrected version of for loop that allows the loop to change negative integers starting from -12 going up by 1 until 20:

run_count=20-(-12)+1; % the number of times loop run
for k=1:run_count
i=-12;
AOA(k)=i;
CL(k)=a*(AOA(k)-alp0);
fprintf(fid, '%8.4f %8.4f ',AOA(k),CL(k));
end