Filter löschen
Filter löschen

finding index of minimum or maximum in tall array

1 Ansicht (letzte 30 Tage)
lalikesbrains
lalikesbrains am 17 Sep. 2019
Kommentiert: lalikesbrains am 20 Sep. 2019
I'm tryin to find the index of the minimum and maximum of each row in a tall mxn array because I need to determine the number of elements between the max and min for each row. Does anyone have any ideas for how I could do this?
Here's what I've got.
% A is a 100 x 48 tall array
% minA is what I'm using to contain the minimum of each row and the index of the minimum
% maxA contains the maximum of each row and the index of the maximum
minA(:,1) = min(A(:,5:20),[],2); % I only want the minimum value between the 5th and 20th elements
min(:,2) = % index of minA(:,1) for each row + 4 because I'm only searching from the 5th element onwards
% the maximum needs to be the maximum between the minimum element and the 40th element. To do this I need the index of the minimum element.
maxA(:,1) = max(min(:,2):40,[],2);
maxA(:,2) = %index of maxA(:,1) for each row + index of minA bevause I'm only searching from minA onwards.
width(:) = maxA(:,2)-minA(:,2); % width is the number of elements between the min and max for each row
%%
% if this was a regular array and not a tall array, the functions min and max would also return an index,
% but since it's tall, I can't get an index from the function. I've tried find:
find(A(:,(5:20)) == minA(:,1)) % This does not work.
help!
  2 Kommentare
Jalaj Gambhir
Jalaj Gambhir am 20 Sep. 2019
Is it required to store data in tall array format?
lalikesbrains
lalikesbrains am 20 Sep. 2019

The data is too big for memory which is why I've been trying to use tall arrays. Is there any other technique that would work?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by