Borrar filtros
Borrar filtros

How can I find midpoint in a structure of rows?

2 visualizaciones (últimos 30 días)
Abbas Alali
Abbas Alali el 26 de Jun. de 2021
Comentada: Abbas Alali el 27 de Jun. de 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

Respuesta aceptada

Chunru
Chunru el 26 de Jun. de 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 comentario
Abbas Alali
Abbas Alali el 27 de Jun. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by