different parts of a matrix

1 回表示 (過去 30 日間)
Guido Pastore
Guido Pastore 2019 年 3 月 20 日
コメント済み: KSSV 2019 年 3 月 20 日
Given a matrix of 900 rows and 15 columns.
- How can I take the entire first column from line 3?
- Always from the first column how do I take portions of the column (for example that goes from line 33 to line 58) ??
  3 件のコメント
Guillaume
Guillaume 2019 年 3 月 20 日
This sounds like homework on the basics of matlab indexing. This is covered in the Getting started tutorial and in any introductory textbook on matlab.
If you are not able to figure the answer to these on your own, I'm afraid you will struggle a lot with matlab.
Guido Pastore
Guido Pastore 2019 年 3 月 20 日
I Know that if i want to get the first column of my matrix M i must do:
column_1 = M(:,1); ok
But, now i want to get another column equal to column_1 but without the first two rows.
How can i do?

サインインしてコメントする。

採用された回答

KSSV
KSSV 2019 年 3 月 20 日
A = rand(900,15) ;
A(3,1) % entire first column from line 3
A(33:58,1) % first column 33 to line 58
Read about MATLAB indexing.
  2 件のコメント
Guido Pastore
Guido Pastore 2019 年 3 月 20 日
thank you
KSSV
KSSV 2019 年 3 月 20 日
This is a very basic question....we strongly advice you to read basics of MATLAB.

サインインしてコメントする。

その他の回答 (1 件)

Andrea Monfredini
Andrea Monfredini 2019 年 3 月 20 日
A = rand(900,15);
first_col = A(3:end,1);
portion = A(33:58,1);
always remember that when you are indexing inside a matrix, the first argument refers to the rows while the second argument refers to columns. inside these arguments you can pass vectors that contain the keys for rows and columns elements you are interested in (like the number and letter of a labeled seat in a Cinema).
so in this excercize, you want the first column, so the second argument will be always a vector containing only the lement "1", while for the rows you build:
  • a vector [3 4 5 6 ... end] to take the last n_rows - 2 elements
  • a vector [33 34 35 ... 58] to take the portion of interest.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by