Extracting the closest possible value having the same indices

조회 수: 1 (최근 30일)
Ganesh Kini
Ganesh Kini 2020년 5월 28일
댓글: Ganesh Kini 2020년 5월 29일
t1 = 2.3
t2 = 5.6
%its is a 2*7*1*10*10*15*8 matrix
p = period_arr(1,:,:,:,:,:,:); % this is of the form p = period_arr(i1, i2, i3, i4, i5, i6, i7);
n = period_arr(2,:,:,:,:,:,:); % this is of the form n = period_arr(i1, i2, i3, i4, i5, i6, i7);
dist_p = abs(p - t1);
[min_dist_p, idx_p] = min(dist_p(:));
dist_n = abs(n - t2);
[min_dist_n, idx_n] = min(dist_n(:));
c_tp = p(idx_p);
c_tn = n(idx_n);
So based on the minimum distance I get the closest value, and it is working fine.
But, I have a problem where I have to get only the closest value where the indices i4 of p = i4 of n and i5 of p = i5 of n. It should regulate the same value for both p and n.
How can I do that? Please help me out. I've been stuck on this problem from 2 days.
For example, I can have
2.6 = period_arr(1,:,:,a,b,:,:)
7.8 = period_arr(2,:,:,a,b,:,:)
  댓글 수: 6
Ganesh Kini
Ganesh Kini 2020년 5월 29일
I have checked this yesterday, but this is not the solution that i am looking for.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by