필터 지우기
필터 지우기

Find the threshold point in a matrix

조회 수: 1 (최근 30일)
MByk
MByk 2017년 11월 22일
댓글: MByk 2017년 11월 23일
I have a 178x13 double matrix. In each column there is a point where each data value starts to stay same. I want to find them (row number). For example for the first column it is 70. I tried "find(diff(values(:,1)) == 0, 1, 'first')" but it is not working. How can I do this? Thanks for the help.

채택된 답변

Image Analyst
Image Analyst 2017년 11월 22일
You can have differences equal to zero that are not in the last stretch of zeros. Therefore you need to use findgroups() or regionprops() to find the first element of the last group of zeros. If you need a demo, attach your data in an mat file with the paper clip icon.
  댓글 수: 3
Image Analyst
Image Analyst 2017년 11월 23일
That's not a great example because all those columns go steady state at exactly the same row. This simple code will do it quickly:
data = importdata('myfile.txt')
[rows, columns] = size(data)
for col = 1 : columns
fprintf('Finding where column #%d equals %f . . . ', col, data(end, col));
steadyStateLocations(col) = find(data(:, col) ~= data(end, col), 1, 'last');
fprintf('it happens at row %d.\n', steadyStateLocations(col));
end
MByk
MByk 2017년 11월 23일
Thank you very much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by