MATLAB Question Help It is related to creating indexing and
MATLAB Question! Help. It is related to creating, indexing, and manipulating arrays in MATLAB
Practice creating, indexing, and manipulating arrays in MATLAB. Write a script to manipulate the array A - [21436587 10 9 12 1114 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 repmat([-1 1)4,10) to A). Write a script that creates an array of all 25 primes between 2 and 1000 as follows: create an array containing the values 2 through 1000 remove all multiples of 2 (except 2 itself) remove all multiples of 3 (except 3 itself) remove all multiples of 5 (except 5 itself) remove all multiples of 31 (except 31 itself) Read about the sor-rcws function in MATLAB\'s help documentation and then write a script that creates a 10x5 matrix of random values between 0 and 10 and then sorts it using sortrows. Write a single line of MATLAB code that computes the mean and standard deviation of a 1-dimensional array named A of numbers. You may not use loops, or the mean, variance, or stdev functions. Assume the array A has already been defined. The mean is the arithmetic average of the values in the array, n = a--The variance is the arithmetic average of the squared difference between each value and the mean, sigma^2 = 1/n - 1 Sigma^n_n=1 (a_1 - mu)^2 The standard deviation is the squareroot of the variance,Solution
Write the MATLAB code to sort the array in descending order.
A= [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19];
N=length(A);
for i=1:N
for j=1:N-i
if A(j+1)>A(j)
d=A(j);
A(j)=A(j+1);
A(j+1)=d;
end
end
end
A
A =
Columns 1 through 18
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3
Columns 19 through 20
2 1
