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

need help with Q#5 (4) using Matlab ev arv from10 to 2t in steps of (0.01)r. Def

ID: 3895235 • Letter: N

Question

need help with Q#5 (4) using Matlab

ev arv from10 to 2t in steps of (0.01)r. Define an array of distances r RI=5*cos(4*0) al make a polar plot of r versus 0 with a red color line. using the same 0 array as in (a) Write a script which performs the following operations (in sequence) (i) Q#5 creates a 20 x 40 array, A, in which each element (or entry) in rows l through 10 is assigned the value 1 and each element in rows 11 through 20 is assigned the value 2; creates a new 20x40 array, B, which is the same as A except row I1 for which B( 1 I j) = 1/j, for 1 js 40; (ii) (ii) (iv) creates a new 20 x 41 array, C, which is the same as B for columns 1 through 40 but also includes a column 41 in which all clements are assigned the value 3; creates a new 20x 41 array, P, which is the same as C except the first ten entries on the main diagonal for which PG,i)-i * C(i,i), for l s is 10:

Explanation / Answer

ScreenShot

--------------------------------------------------------------------

Program

%Q#5 i)
A=zeros(20,40);%Create anarray
%loop to put value 1 from 1-10 rows
for i=1:10
for j=1:40
A(i,j)=1;
end
end
%loop to put value 2 from 11-20 rows
for i=11:20
for j=1:40
A(i,j)=2;
end
end
%display array A
A
%Q#5 ii)
B=zeros(20,40);%Create anarray
%loop to put value 1 from 1-10 rows
for i=1:10
for j=1:40
B(i,j)=1;
end
end
%loop to put value 2 from 11-20 rows
for i=11:20
for j=1:40
B(i,j)=2;

end
end
%loop to put value 1/j in 11th row
for j=1:40
B(11,j)=1/j;
end
%display array B
B
%Q#5 iii)
C=zeros(20,41);%Create anarray
%loop to put value 1 from 1-10 rows
for i=1:10
for j=1:40
C(i,j)=1;
end
end
%loop to put value 2 from 11-20 rows
for i=11:20
for j=1:40
C(i,j)=2;
end
end
%loop to put value 1/j in 11th row
for j=1:40
C(11,j)=1/j;
end
%loop to put value 3 in 41th column
for i=1:20
C(i,41)=3;

end
%display C array
C
%Q#5 iV)
P=zeros(20,41);%create an array
%loop to put value 1 from 1-10 rows
for i=1:10
for j=1:40
P(i,j)=1;
end
end
%loop to put value 2 from 11-20 rows
for i=11:20
for j=1:40
P(i,j)=2;
end
end
%loop to put value 1/j in 11th row
for j=1:40
P(11,j)=1/j;
end
%loop to put value 3 in 41th column
for i=1:20
P(i,41)=3;
end
%loop to put values in diagonals of the rows from 1-10
for i=1:10
P(i,i)=i*C(i,i);
end

%display P Array
P