create simple time window

조회 수: 9 (최근 30일)
Jonas Bender
Jonas Bender 2023년 9월 13일
답변: Mahmoud 2023년 10월 22일
Dear all,
it seems to be simple but I don't get it. I wrote a script to get a synchronization index for a 7 minute walk:
%% compute the phase angle difference
for i = 1:numel (data_trimmed_al)
data_trimmed_al(i).phase_angle = angle (data_trimmed_al(i).hilbertx_hinweg_norm);
data_trimmed_al(i).phase_angle_difference = (data_trimmed_al(i).phase_angle (:,1) - data_trimmed_al(i).phase_angle (:,2));
end
% Euler representation of phase angle difference
for i = 1:numel (data_trimmed_al)
data_trimmed_al(i).euler_phase_angle_difference = exp (1i * data_trimmed_al(i).phase_angle_difference);
end
% mean vector (in complex space)
for i = 1:numel (data_trimmed_al)
data_trimmed_al(i).mean_vector_complex = mean (data_trimmed_al(i).euler_phase_angle_difference);
end
% ISPC (Synchronization Index)
for i = 1:numel (data_trimmed_al)
% here I would like to insert a loop to calculate the index every 10
% seconds instead of the whole data set.
data_trimmed_al(i).ISPC_together = abs (data_trimmed_al(i).mean_vector_complex);
end
Now, I wan't to calculate the index for every 10 seconds instead of the whole walk of seven minutes.
Do you have any suggestions or advice? I can't find any solutions for my problem.
Regards, Jonas
  댓글 수: 1
Harald
Harald 2023년 9월 18일
Hi Jonas,
I at least fail to understand what needs to be done.
It is not clear to me from the code how it relates to 7 minutes, let alone how to modify it to relate to 10 seconds.
If you can share data and some additional explanation, that might help.
Best wishes,
Harald

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

답변 (1개)

Mahmoud
Mahmoud 2023년 10월 22일
Hi Jonas,
If I understood you correctly you are trying to calculate the Inter-Site Phase Clustering (ISPC) for a 7-minute walk. Currently, your script calculates the ISPC for the entire 7-minute duration. However, you want to modify your script to calculate the ISPC for every 10-second interval during the walk.
To do that I would suggest introducing an additional loop in your script that iterates over the data in 10-second intervals. The exact implementation depends on the sampling rate of the data. Assuming that the data is sampled at a rate of Fs samples per second, a 10-second interval would contain 10*Fs samples.
Fs = ...; % Sampling rate in samples per second
interval = 10 * Fs; % Number of samples in 10 seconds
% Get total number of samples
total_samples = length(data_trimmed_al(1).phase_angle_difference);
% Calculate total number of intervals
total_intervals = floor(total_samples / interval);
for i = 1:numel(data_trimmed_al)
% Preallocate array for ISPC values
data_trimmed_al(i).ISPC_together = zeros(total_intervals, 1);
for j = 1:total_intervals
% Get start and end indices for this interval
start_idx = (j-1)*interval + 1;
end_idx = j*interval;
% Calculate mean vector for this interval
mean_vector_complex = mean(data_trimmed_al(i).euler_phase_angle_difference(start_idx:end_idx));
% Calculate ISPC for this interval
data_trimmed_al(i).ISPC_together(j) = abs(mean_vector_complex);
end
end

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by