How to give the total amount of row from a matrix as a value?

1 回表示 (過去 30 日間)
Emerson De Souza
Emerson De Souza 2011 年 3 月 30 日
I need to define the total amount of row of a matrix as a variable
and don't how to extract this number.
For example, let
M=
1 2
2 4
3 6
4 8
5 10
In this case the row number would be 5.
I thought there would be a command such as
row(M)
but did not work.
Hopefully someone knows how to solve this
Thank you for your help
Emerson

採用された回答

Matt Fig
Matt Fig 2011 年 3 月 30 日
size(M,1) % The number or rows of an array.
size(M,2) % The number of columns of an array.
also,
S = size(M);
S(1) % The same as size(M,1)
S(2) % The same as size(M,2)
In general,
A = rand(4,5,2,2);
S = size(A)
notice the connection between S and the argument to RAND.
  1 件のコメント
Emerson De Souza
Emerson De Souza 2011 年 3 月 30 日
Hi Matt Fig,
thank you again for your fast reply.
That was all what I needed.
I'm working tonight, may
be you will find more questions.
Or, I wish you a nice night
Emerson

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

その他の回答 (1 件)

Teja Muppirala
Teja Muppirala 2011 年 3 月 30 日

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by