Get separate index from a column with separate conditions
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have the following script with the attached files. I extracting two separate indexes from a column to find specific acceleration values values that matches the "index_initial_time" and "index_final_time" in a for loop. However, the second index ("index_final_time") is not capture properly, which does not allow to estimate the mean of the two acceleration values capture in the next lines. Could you please helpe on this. I would appreciate the help.
clear all
clc
SIGNAL = load('Time_Acceleration.txt');
X_spike_matrix=load('X_spike_matrix.txt');
n_spikes_X=height(X_spike_matrix);
TIME=SIGNAL(:,1);
ACCX=SIGNAL(:,2);
DT=TIME(2,1)-TIME(1,1);
ACCX_spikes_removed=ACCX;
for k=1:n_spikes_X;
initial_time_ACCX=X_spike_matrix(k,1)-DT; %t-DT time to corresponding acceleration value
final_time_ACCX=X_spike_matrix(k,1)+DT; %t+DT time to corresponding acceleration value
index_initial_time=find(TIME==initial_time_ACCX);
index_final_time=find(TIME==final_time_ACCX);
initial_ACCX=ACCX(index_initial_time,:); %t-DT acceleration to compute average replacement
%% line with issue
final_ACCX=ACCX(index_final_time,:); % t+DT acceleration to compute average replacement
%%
mean_ACCX_replacement=mean([initial_ACCX,final_ACCX]); %estimation of mean neibouring value to replace peak value
matrix_ACCX_neighbour_mean(k,1)=mean_ACCX_replacement; %acumulating corrected peak values in a matrix
ACCX_spikes_removed(TIME==X_spike_matrix(k,1))=mean_ACCX_replacement; %replacement of the peak value with the mean nenighbouring value
end
However, line 20 does not capture the next index value
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!