Select elements of Matrix?
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a 20x20 matrix, P. I wish to define a matrix Q such that the rows of Q are the LAST 18 rows of P (rows 2-20), and the columns of Q are the last 18 columns of P (columns 2-20).
0 件のコメント
採用された回答
その他の回答 (2 件)
C.J. Harris
2014 年 12 月 3 日
Like so:
P = magic(20);
Q = P(end-17:end,end-17:end);
Or this, as I assume you mean rows/columns 3 to 20 - otherwise you'll have 19 rows/columns:
P = magic(20);
Q = P(3:20,3:20);
0 件のコメント
Azzi Abdelmalek
2014 年 12 月 3 日
編集済み: Azzi Abdelmalek
2014 年 12 月 3 日
P=rand(20) % Example
n=18
Q=P(end-n+1:end,end-n+1:end)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!