How to find the value before max value for vector for each 10 rows
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
abdullah al-dulaimi
am 29 Dez. 2022
Kommentiert: abdullah al-dulaimi
am 29 Dez. 2022
i have a vector , A=1:1:100
I want to find the values befor max values , so the result wii be, 9 19 29 39 49 59 69 79 89 99
0 Kommentare
Akzeptierte Antwort
Karim
am 29 Dez. 2022
Hi see below for the stept to obtain such a vector
% set up the 'max row value indicator'
n = 10
% create array A
A = 1:100
% reshape into a matrix with a given numeber of elements:
B = reshape(A, [], n)
% find the max element for each group (which in this case has 10 elements),
% but we exclude the last (i.e. 10th) elements
maxval = max(B(1:end-1,:),[],1)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!