how can i find row position for minimum value that changes every cycle. each cycle has 100 data points( 100*1 matrix).

1 次查看(过去 30 天)
example: 1st 100 data points (1 to 100)- minimum is at 20th row 2nd 100 data points (101 to 200) - minimum is at 150th row. and so on. I have 6000 cycles. How do I find the minimum for each cycle and their position?

采纳的回答

Jan
Jan 2017-4-19
编辑:Jan 2017-4-19
X = rand(1, 6000);
[minValue, minIndex] = min(reshape(X, 100, []));
Now the minIndex is related to each block. To get the absolute positions relative to X:
minIndex = minIndex + 0:numel(minIndex) - 1;
  5 个评论
Utsav Vishal
Utsav Vishal 2017-4-20
编辑:Utsav Vishal 2017-4-20
I want to do it this way, eg: 6 9 8 4 5 6 3 4 12 8 As minimum value(3) is in the 7th position. I would like to place it to the 1st position without changing the sequence. such as: 3 4 12 8 6 9 8 4 5 6. Also keeping in mind that the position of min. value is different for each column. eg[5 4 3 1 2, 8 6 4 5 7] to [1 2 5 4 3, 4 5 7 8 6]. Thank you.
Jan
Jan 2017-4-20
This means, that you want to roll the vector to the left - correctly?
X = rand(1, 6000);
Y = reshape(X, 100, []);
[minValue, minIndex] = min(Y);
for k = 1:size(Y, 2)
Y(:, k) = circshift(Y(:, k), 1 - minIndex(k));
end

请先登录,再进行评论。

更多回答(1 个)

Are Mjaavatten
Are Mjaavatten 2017-4-19
You could arrange your 6000 data cycles in a 100 by 6000 matrix and use the min function. Example, using only 10 cycles:
X = rand(100,10):
min_values = min(X);

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by