Reorder matrix rows or columns
- Library:
- DSP System Toolbox / Math Functions / Matrices and Linear Algebra / Matrix Operations
The matlab statistics package bootstrap Preliminaries: The matlab function eval: EVAL Execute string with MATLAB expression. EVAL(s), where s is a string, causes MATLAB to execute the string as an expression or statement. EVAL(s1,s2) provides the ability to catch errors. It executes string s1 and returns if the operation was successful. I need to implement the following algorithm in Matlab. Suppose A = 3 4 1 9 5 permute A randomly say, A = 5 1 4 3 9 Add 2 to the first two elements: A = 7 3 4 3 9 permute A back, A = 3 4 3 9.
Description
![Matlab Matlab](https://la.mathworks.com/help/examples/dsp/win64/PermuteMatrixByRowOrColumnExample_01.png)
The Permute Matrix block reorders the rows or columns of an M-by-N input matrix
A
as specified by indexing input P
.Ports
Input
Input matrix, specified as a scalar, vector, or matrix.
Data Types:
single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
| enumerated
Index matrix, specified as a scalar or vector.
Data Types:
single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| enumerated
Output
Output signal, specified as a vector or matrix.
Data Types:
single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
| enumerated
Parameters
Smooze 1 1 21. Method of constructing the output matrix by permuting rows or columns of the input.
Permute Matlab Code
When the Permute parameter is set to: Car mechanic simulator 2018 free download.
Rows
–– The block uses the rows ofA
to create a matrix that has the same column dimension. InputP
is a length-L vector whose elements determine where each row fromA
must be placed in the L-by-N output matrix.For row permutation, the block treats the length-M unoriented vector input at the portA
as an M-by-1 matrix.Columns
–– The block uses the columns ofA
to create a matrix that has the same row dimension. InputP
is a length-L vector whose elements determine where each column fromA
must be placed in the M-by-L output matrix.For column permutation, the block treats the length-N unoriented vector input at portA
as a 1-by-N matrix.
Index mode
— Index mode
Zero-based
(default) | One-based
When set to
One-based
, a value of 1
in the permutation vector P
refers to the first row or column of the input matrix A
. When set to Zero-based
, a value of 0
in P
refers to the first row or column of A
.Invalid permutation index
— Response to an invalid index value
Clip index
(default) | Clip and warn
| Generate error
Response to an invalid index value. When an index value in input
P
references a nonexistent row or column of matrix A
, the block reacts as specified in this parameter. These options are available:Clip index
–– Clip the index to the nearest valid value (1 or M for row permutation and 1 or N for column permutation) and do not issue an alert. Example: For a 3-by-7 input matrix, a column index of 9 is clipped to 7 and a row index of -2 is clipped to 1.Clip and warn
–– Display a warning message in the MATLAB® Command Window and clip the index as described in the preceding bullet.Generate error
–– Display an error dialog box and terminate the simulation.
Tunable: Yes
Error when length of P is not equal to Permute dimension size
— Error message for P length
off
(default) | on
Option to display an error dialog box and terminate the simulation when the length of the permutation vector
P
is not equal to the number of rows or columns of the input matrix A
.3dweather 2 1 1. You can choose to open an error dialog box and terminate the simulation by setting this parameter to
on
.Model Examples
Simulink® model example that shows how to permute a matrix by rows or columns.
Permute In Matlab
The application envisioned for this example is automatic lane tracking on a road. We will show how to fit a polynomial to noisy data representing the lane boundary of the road ahead of a vehicle.
Block Characteristics
Data Types | Boolean | double | enumerated | fixed point | integer | single |
Direct Feedthrough | no |
Multidimensional Signals | no |
Variable-Size Signals | no |
Zero-Crossing Detection | no |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Generated code relies on
memcpy
or memset
functions (string.h
) under certain conditions.Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
See Also
Blocks
- Submatrix | Variable Selector
Permute Matrix Matlab
Functions
Topics
Matlab Permute In Python
Introduced before R2006a