Row sort Write a function called CustomSort that takes an nx m 2D array inMat with random integers between -100 and 100 (inclusive), and produces an n x m array called outMat, which consists of sorted values in inMat such that the lowest value in inMat is the (1,1) position in outMat. CustomSort orders the remaining elements from left to right on the first row until the last column, progressing with each row. Hint: The internal functions sort and reshape should be used. Restrictions: Loops should not be used. Ex: inMat = [ 8 19 8 11 17 6 12 16 12 16 2 19 11 16 3]; [outMat] = CustomSort( inMat ) produces outMat = 2 3 6 8 8 11 11 12 12 16 16 16 17 19 19 Function e A Save CReset I MATLAB Documentatio 1 function [outMat] = CustomSort( inMat ) 2 % Takes a 2D array inMat with random integers between (inclusively) -100 and 100, 3 % and produces a n by m array outMat that consists of sorts values 4 % in inMat such that the lowest value in inMat is the (1,1) position 5 % in outMat, and order the remaining elements left to right on 6 % the first row till last column, starting with the next row and so on. 7 8 % Your code goes here % 9 10 end 11 Code to call your function 0 C Reset 1 inMat=randi(10,4,4)-5; 2 [outMat] = CustomSort( inMat )

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

Please answer in matlab code.

Row sort
Write a function called CustomSort that takes an n x m 2D array inMat with random integers between -100 and 100 (inclusive), and
produces an n x m array called outMat, which consists of sorted values in inMat such that the lowest value in inMat is the (1,1) position in
outMat. CustomSort orders the remaining elements from left to right on the first row until the last column, progressing with each row.
Hint: The internal functions sort and reshape should be used.
Restrictions: Loops should not be used.
Ex:
inMat =
[
8
19
8
11
17
6.
12
16
12
16
2
19
11
16
2
3];
[outMat]
= CustomSort( inMat )
produces
outMat =
2
3
8
11
11
12
12
16
16
16
17
19
19
Function
법 Save
C Reset
MATLAB Documentation
1 function [outMat]
CustomSort( inMat )
2 % Takes a 2D array inMat with random integers between (inclusively) -100 and 100,
3 % and produces a
n by m array outMat that
consists of sorts values
4 % in inMat such that the lowest value in inMat is the (1,1) position
5 % in outMat, and order the remaining elements left to right on
6 % the first row till last column, starting with the next row and so on.
7
8
% Your code goes here %
| 6
10 end
11
Code to call your function e
C Reset
1 inMat=randi(10,4,4)-5;
2 [outMat] = CustomSort( inMat )
Transcribed Image Text:Row sort Write a function called CustomSort that takes an n x m 2D array inMat with random integers between -100 and 100 (inclusive), and produces an n x m array called outMat, which consists of sorted values in inMat such that the lowest value in inMat is the (1,1) position in outMat. CustomSort orders the remaining elements from left to right on the first row until the last column, progressing with each row. Hint: The internal functions sort and reshape should be used. Restrictions: Loops should not be used. Ex: inMat = [ 8 19 8 11 17 6. 12 16 12 16 2 19 11 16 2 3]; [outMat] = CustomSort( inMat ) produces outMat = 2 3 8 11 11 12 12 16 16 16 17 19 19 Function 법 Save C Reset MATLAB Documentation 1 function [outMat] CustomSort( inMat ) 2 % Takes a 2D array inMat with random integers between (inclusively) -100 and 100, 3 % and produces a n by m array outMat that consists of sorts values 4 % in inMat such that the lowest value in inMat is the (1,1) position 5 % in outMat, and order the remaining elements left to right on 6 % the first row till last column, starting with the next row and so on. 7 8 % Your code goes here % | 6 10 end 11 Code to call your function e C Reset 1 inMat=randi(10,4,4)-5; 2 [outMat] = CustomSort( inMat )
Dizzy Shift
Write a function called Shifter that takes a 2D array inArray and i) creates an array circLeft that contains the circular left shift by one
position of all the columns of inArray in a 2D array, ii) creates an array called circUp that contains the circular up shift by one position of all
the rows of inArray, and iii) creates an array called circ2x that first circularly shifts the columns of inArray by one position, and with the
resulting array, shifts all the rows up by one position. The function must operate on a 2D array of any size.
Hint: Array indexing, single colon and end should be used.
Restrictions: For loops, while loops, circshift, and any other internal functions should not be used.
Ex:
inArray
[6,7,4;
10,1,5;
2,9,5];
[ circleft, circUp, circ2x ] = Shifter( inArray )
produces
circLeft =
7
4
1
10
5
circup =
10
1
2
9
5
7
4
circ2x =
1
5
10
9.
5
7
4
6
Function
A Save
C Reset
I MATLAB Documentation
1 function [ circLeft, circUp, circ2x]
Shifter( inArray )
3
% Your code goes here %
4
5 end
Code to call your function e
C Reset
1 inArray
[6,7,4; 10,1,5; 2,9,5];
2 [ circleft, circUp, circ2x ] = Shifter( inArray )
Transcribed Image Text:Dizzy Shift Write a function called Shifter that takes a 2D array inArray and i) creates an array circLeft that contains the circular left shift by one position of all the columns of inArray in a 2D array, ii) creates an array called circUp that contains the circular up shift by one position of all the rows of inArray, and iii) creates an array called circ2x that first circularly shifts the columns of inArray by one position, and with the resulting array, shifts all the rows up by one position. The function must operate on a 2D array of any size. Hint: Array indexing, single colon and end should be used. Restrictions: For loops, while loops, circshift, and any other internal functions should not be used. Ex: inArray [6,7,4; 10,1,5; 2,9,5]; [ circleft, circUp, circ2x ] = Shifter( inArray ) produces circLeft = 7 4 1 10 5 circup = 10 1 2 9 5 7 4 circ2x = 1 5 10 9. 5 7 4 6 Function A Save C Reset I MATLAB Documentation 1 function [ circLeft, circUp, circ2x] Shifter( inArray ) 3 % Your code goes here % 4 5 end Code to call your function e C Reset 1 inArray [6,7,4; 10,1,5; 2,9,5]; 2 [ circleft, circUp, circ2x ] = Shifter( inArray )
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,