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

조회 수: 10 (최근 30일)
  댓글 수: 8
Wesley
Wesley 2020년 12월 11일
In so much data, find the largest y1, y2 and the coordinates of their respective points.

댓글을 달려면 로그인하십시오.

채택된 답변

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
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 CenterFile Exchange에서 3-D Scene Control에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by