How can I find midpoint in a structure of rows?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abbas Alali
am 26 Jun. 2021
Kommentiert: Abbas Alali
am 27 Jun. 2021
Hello everyone,
I am trying to find every midpoint value between the min and max points that is in a row within a sturcture of rows.
Lumbar.Lift.AllMin = min(lumbar_lift,[],2);
Lumbar.Lift.AllMax = max(lumbar_lift,[],2);
This has worked with me so far. However, when I use the code below, it gives me weird values that are definetely not between the these values:
Lumbar.Lift.Allmid = min(abs(lumbar_lift-((Lumbar.Lift.AllMax + Lumbar.Lift.AllMin))/2),[],2);
your help is appirciated
0 Kommentare
Akzeptierte Antwort
Chunru
am 26 Jun. 2021
a = randn(3, 10);
[nrows, ncols] = size(a);
[amin, imin] = min(a, [], 2)
[amax, imax] = max(a, [], 2)
amed = median(a, 2)
% mid points
for i=1:nrows
[~, imid] = min(abs(a(i, :)-(amin(i) + amax(i))/2)); % Get the index that coloset to the "mid point"
amid(i, 1) = a(i, imid);
end
amid
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!