SORT(MATLAB HELP!) Program Description: The purpose of this program is to read i
ID: 3685894 • Letter: S
Question
SORT(MATLAB HELP!)
Program Description: The purpose of this program is to read in design rating data from the file named Data_11_1.txt.
The data is output in table form in its original form then sorted in descending order according to the cost, durability, function, marketability, and total score columns.
Required txt file : Data_11_1.txt
101 7 5 3 8
102 10 8 9 7
103 4 9 5 9
104 8 7 10 6
105 2 10 7 5
Desired Output:
Original Design Ratings Design # Cost Durability Function Marketability Total 23 34 27 31 24 101 10 103 104 105 10 10 R 113 Shifted by the Descending Orde of the cost column Design # Cost Durability Functionarketability Total 102 104 101 10 34 31 23 27 24 105 10 Rovs Shifted by the Descending Order of the Durability Column Design Cost Durability Function arketability Total 105 103 102 10 24 27 34 31 23 10 10 101 Rows Shifted by the Descending Order of the Function Column Design # Cost Durability Function Marketability Total 104 31 34 24 27 23 10 10 105 103 101 10Explanation / Answer
Inititally we have to create a matrix:
i.e matrix=[101 7 5 3 8
102 10 8 9 7
103 4 9 5 9
104 8 7 10 6
105 2 10 7 5]
then we can directly use function sort(rows,2,descending).It directly sorts the second column of given matrix.
Then similarly for third column i.e sort(rows,3,descending)
and for fourth column i.e sort(rows,4,descending)
and for fifth column i.e sort(rows,5,descending)
For finding the sum of columns with descending order then simply use sum(matrix,2).
CODE:
A=[101 7 5 3 8
102 10 8 9 7
103 4 9 5 9
104 8 7 10 6
105 2 10 7 5]
sort(rows,2,descending)//for every column
then simply find sum
i.e s=sum(a,2)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.