How to access number of rows in one step?

1 回表示 (過去 30 日間)
wit221
wit221 2016 年 12 月 9 日
コメント済み: wit221 2016 年 12 月 9 日
I have a matrix:
theMatrix = [2 3 4;5 3 2];
I can access the number of rows in the following two steps:
matrixSize = size(theMatrix);
rows = matrixSize(1);
Why can I not access it using the following?
rows = size(theMatrix)(1)
or
rows = (size(theMatrix))(1)
?
In my understanding size(theMatrix) returns a 1x2 vector, so that expression is: (1x2 vector)(1), which means return 1st value of vector. That is why I am confused.
[rows columns] = size(myMatrix); creates a redundant variable column. I do not want to know the number of columns - just the number of rows.

採用された回答

Mischa Kim
Mischa Kim 2016 年 12 月 9 日
Try
size(theMatrix,1)
  1 件のコメント
wit221
wit221 2016 年 12 月 9 日
Thank you. Next time I will remember to verify the function documentation using help [function]!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by