Effacer les filtres
Effacer les filtres

How can I find midpoint in a structure of rows?

2 vues (au cours des 30 derniers jours)
Abbas Alali
Abbas Alali le 26 Juin 2021
Commenté : Abbas Alali le 27 Juin 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

Réponse acceptée

Chunru
Chunru le 26 Juin 2021
a = randn(3, 10);
[nrows, ncols] = size(a);
[amin, imin] = min(a, [], 2)
amin = 3×1
-1.4505 -1.8692 -2.4076
imin = 3×1
9 2 7
[amax, imax] = max(a, [], 2)
amax = 3×1
1.8287 1.0523 0.6824
imax = 3×1
8 5 10
amed = median(a, 2)
amed = 3×1
0.5678 -0.3628 -0.6928
% 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
amid = 3×1
0.1543 -0.6789 -0.7695
  1 commentaire
Abbas Alali
Abbas Alali le 27 Juin 2021
Thank you, this has worked with me. but it gave me the values in rows and I wanted them in coumns. I tried using the transpose function, A.', A' , but non of these have worked with me. Any sugesstion? Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by