ouble or char) NxN array (N>=2) 2. (char) 1x5 array containing the sort instructions Output: 1. (double/char) NxN sorted array according to the sort instructions Function Description: You are given a square NxN array of either numbers or characters. The second input tells you how to sort it. . The first character is the number of the row or column that you will be sorting by . The next three characters instruct you to sort using the row ('row') or column ('co . The last character instructs you whether to sort in ascending ('A') or descending ('D') order by the first character Your function should return the given array sorted by the given criteria. No conditional (e.g. if or switch) or iteration (e.g. for or while) statements can be used to solve this problem. Hint(s); • Use of the str2num(), sort(),
MATLAB
Function: sortThis
Input:
1. (double or char) NxN array (N>=2)
2. (char) 1x5 array containing the sort instructions
Output: 1. (double/char) NxN sorted array according to the sort instructions
Function Description: You are given a square NxN array of either numbers or characters. The second input tells you how to sort it. . The first character is the number of the row or column that you will be sorting by . The next three characters instruct you to sort using the row ('row') or column ('co . The last character instructs you whether to sort in ascending ('A') or descending ('D') order by the first character Your function should return the given array sorted by the given criteria.
No conditional (e.g. if or switch) or iteration (e.g. for or while) statements can be used to solve this problem.
Hint(s); • Use of the str2num(), sort(), repelem() and reshape() functions ny be helpful
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images