create simple time window
9 次查看(过去 30 天)
显示 更早的评论
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
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!