For a matrix with an unknown number of rows, how to find the number of rows n and transform it into n matrices.

4 ビュー (過去 30 日間)
  8 件のコメント
Wesley
Wesley 2020 年 12 月 11 日
In so much data, find the largest y1, y2 and the coordinates of their respective points.
Wesley
Wesley 2020 年 12 月 11 日
B=A, expand into A=[A1 A2 A3 A4].

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 11 日
編集済み: Ameer Hamza 2020 年 12 月 11 日
You can find the number of rows in a matrix using size()
data1;
n = size(data,1)
or height() [only in R2020b and later]
data1;
n = height(data)
The second part of your question about transforming it into a matrix is not clear.

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 11 日
編集済み: Ameer Hamza 2020 年 12 月 11 日
I guess you are trying to do something like this
rows = data1(:,2);
cols = data1(:,1);
M = zeros(max(rows), max(cols));
idx = sub2ind(size(M), rows, cols);
M(idx) = 1;
Result
>> imshow(M)
  4 件のコメント
Wesley
Wesley 2020 年 12 月 11 日
The two largest numbers in a column.
Ameer Hamza
Ameer Hamza 2020 年 12 月 11 日
You can use maxk() to get two largest values. For example
maxk(data1, 2)
gives 2 highest values in both columns.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by