MATLAB Answers


Find the threshold point in a matrix

さんによって質問されました 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.

  0 件のコメント

サインイン to comment.


1 件の回答

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 件のコメント

2017 年 11 月 23 日
I saved the matrix as a txt file.
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));
2017 年 11 月 23 日
Thank you very much.

サインイン to comment.

Translated by