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

Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16

ID: 3683655 • Letter: W

Question

Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19] to be in descending order without using the sort function. You must do everything using array manipulation in MATLAB (i.e. you cannot sort it by hand and then hardcode it, you cannot simply create the array 1:20, you cannot simply add .rej3mat(J-l 1],1,10) to A). Write a script that creates an array of all 25 primes between 2 and 1000 as follows: a. create an array containing the values 2 through 1000 b. remove all multiples of 2 (except 2 itself) c. remove all multiples of 3 (except 3 itself) d. remove all multiples of 5 (except 5 itself) e. ... f. remove all multiples of 31 (except 31 itself)

Explanation / Answer

X = [2:1000];
X=X(mod(X,2)!=0);
X=X(mod(X,3)!=0);
X=X(mod(X,5)!=0);
X=X(mod(X,7)!=0);
X=X(mod(X,11)!=0);
X=X(mod(X,13)!=0);
X=X(mod(X,17)!=0);
X=X(mod(X,19)!=0);
X=X(mod(X,23)!=0);
X=X(mod(X,29)!=0);
X=X(mod(X,31)!=0);
X
x=[2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19];
x2=[1:length(x)]
for k=1:length(x)
[C I]=min(x);
x(I)=[];
x2(k)=min(x);
end

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