Problem finding the nearest value to specific number
Afficher commentaires plus anciens
Hello,
I am using this code seen in this thread:
%Initial amplitud (50%time - 10%time)
time_10=((max(A)-min(A))*0.1)+min(A);
time_50=((max(A)-min(A))*0.5)+min(A);
[~,~,idx]=unique(abs(A-time_10));
[~,~,idx2]=unique(abs(A-time_50));
minVal_10=A(idx==1);
minVal_50=A(idx2==1);
T10=find(A==minVal_10); %Gives you the row where 10% of the time lies in the Intensity matrix
T50=find(A==minVal_50); %Gives you the row where 50% of the time lies in the Intensity matrix
I_T10=B1(T10,1);
I_T50=B1(T50,1);
ini_Amp=(I_T50-I_T10)*10^6;
However, I have problems with minVal_50. there are two values equally near to time_50. Therefore I got this warning:
Matrix dimensions must agree.
Error in foot_signal_analysis1 (line 60)
T50=find(A==minVal_50); %Gives you the row where 50% of the time lies in the Intensity matrix
T50=10.53350, and minVal_50 is either 10.53352 or 10.53348. How can I code to take the biggest number in this case? If statement?
Réponses (1)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!