How is it possible to get new matrix with some values of another matrix?

1 visualizzazione (ultimi 30 giorni)
Hello, i'v got table(matrix) S with 907x1280 elements in array, what script should i write to get, for example, all values in columns from 200 till 700 with step 25, every 25 row. All new data should be in the new matrix.

Risposta accettata

Siyu Guo
Siyu Guo il 27 Apr 2018
This is the very elementary array index operation. To retrieve the specified data, just use
S(:, 200:25:700)
If you'd like the retrieved columns to form a new matrix by their relative positions in S, simply code
A = S(:, 200:25:700)
A is an m-by-201 matrix, m being the number of rows of S. If you'd like to assign the extracted data to a portion of a new matrix, make sure that the destination portion can also be arranged as an m-by-201 matrix, e.g.,
A(3:m+2, 5:2:405) = S(:, 200:25:700)
A being the already allocated new matrix (hope I haven't made mistakes).

Più risposte (0)

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by