help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting the closest value having the same index value


From: GK19
Subject: Getting the closest value having the same index value
Date: Thu, 28 May 2020 11:30:14 -0500 (CDT)

t1 ´ = 2.3
t2 = 5.6
p = zeros (length (ring_vec), length (opcon_vec), length (rccorner_vec),
.... )% writing all the length of all the vec files
n = zeros (length (ring_vec), length (opcon_vec), length (rccorner_vec),
.... )%
for ioc = 1: 1: length (ring_vec)
for ipc = 1: 1: length (opcon_vec)
for irc = 1: 1: length (rccorner_vec)
for inw = 1: 1: length (vnw_vec)        
for ipw = 1: 1: length (vpw_vec)
for ivdp = 1: 1: length (vdd_vec)
for itp = 1: 1: length (temp_vec)
% its is a 2 * 7 * 1 * 10 * 10 * 15 * 8 matrix
p (ioc, ipc, irc, inw, ivw, ivdp, itp) = period_arr (ioc ipc, irc, inw, ipw,
ivdp, itp);
n (ioc, ipc, irc, inw, ivw, ivdp, itp) = period_arr (ioc ipc, irc, inw, ipw,
ivdp, itp);
end
end
end
end
end
end
end
Code for picking up the distance and least value
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
But, I have a problem here I have to get only the closest value where the
indices inw of p = inw of n and ipw of p = ipw of n. It should regulate the
same value for both p and n. 




Output example
tp = [2.2, 2.4, 2.5, 2.6]
Looking at this, the closest value is 2.2 or 2.4 wrt t1
2.2 = period`_arr (i1, i2, i3, 4, 5, i6, i7)
2.4 = period`_arr (i1, i2, i3, 3, 1, i6, i7)
tn = [5.2, 5.4, 7.5, 5.8]
Looking at this, the closest value is 5.4 or 5.8 wrt t2
5.4 = period`_arr (i1, i2, i3, 1, 2, i6, i7)
5.8 = period`_arr (i1, i2, i3, 4, 5, i6, i7)
so i should choose 2.2 and 5.8 as the close c_tp and c_tn respectively
since the the indices i4 of p = i4 of n and i5 of p = i5 of n. the other i
values ​​can take any value



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]