Finding minimum within a set of rows below a certain point?

3 次查看(过去 30 天)
I have a matrix X which has a different participant's data (Z) for each row across 10 time points (t) as the columns, I need to find the minimum amount of time and maximum amount of time where Z reaches 2 across the participants.

回答(2 个)

CAM
CAM 2023-4-5
I suggest using the find command (with Z>=2) with row & column as outputs. Find the min and max column values and their associated row (subject). Using these row-column pairs, you can get the times.
  2 个评论
Lucy Shaw
Lucy Shaw 2023-4-5
I haven't come across this before do you ahve an example of the code I would need to use?
Lucy Shaw
Lucy Shaw 2023-4-5
Also would this help me get the maximum time for Z to reach 10, if I am using the maximum function would it not give me the times after it has already reached 10

请先登录,再进行评论。


Duncan Carlsmith
Duncan Carlsmith 2023-4-5
编辑:Duncan Carlsmith 2023-4-5
% Make fake data, rows of random monotonically increasing values.
X=cumsum(rand(10),2)
X = 10×10
0.2407 0.9921 1.6863 2.4363 3.1703 3.9778 4.4172 5.3464 6.1812 6.6070 0.2455 0.9450 1.1133 1.7098 2.1395 2.8970 3.6919 4.3028 5.0397 5.5213 0.7517 1.4867 1.5911 2.5082 3.0390 3.9270 4.2773 4.7528 5.3491 6.0419 0.1739 0.3215 0.4176 0.5598 0.8654 1.4947 1.6105 2.1808 3.1287 3.4387 0.6616 0.8986 1.0563 1.5918 1.6114 2.3840 2.7447 3.4972 3.6497 3.8587 0.5498 1.2241 2.1136 2.1682 2.8959 3.6941 3.8623 4.8417 5.0280 5.2876 0.5449 1.0082 1.7332 2.6481 3.0605 3.7799 4.4520 5.0920 5.0951 5.5473 0.3204 0.5379 1.3796 2.1376 3.1014 3.3773 3.8607 4.6522 5.4181 6.1001 0.0616 0.9671 1.0133 1.6343 2.2013 2.6511 2.8817 2.9395 3.4409 4.1134 0.8321 1.5095 2.1870 3.1504 3.9359 4.8557 5.1856 5.6795 5.6905 5.9523
% Make logical array for values satisfying the condition.
Y=X>2;
% Find the transition points
Z=diff(Y,1,2);
% Get the indices of the transition points.
[row,col]=find(Z==1);
%List the times of transitions.
[B,I]=sort(row);
Times=col(I)'
Times = 1×10
3 4 3 7 5 2 3 3 4 2

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by