필터 지우기
필터 지우기

How can I find midpoint in a structure of rows?

조회 수: 2 (최근 30일)
Abbas Alali
Abbas Alali 2021년 6월 26일
댓글: Abbas Alali 2021년 6월 27일
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

채택된 답변

Chunru
Chunru 2021년 6월 26일
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
Abbas Alali
Abbas Alali 2021년 6월 27일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by