Get separate index from a column with separate conditions
조회 수: 1 (최근 30일)
이전 댓글 표시
Jorge Luis Paredes Estacio
2023년 7월 21일
댓글: Jorge Luis Paredes Estacio
2023년 7월 21일
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!