I need help setting my formula in a loop

조회 수: 1 (최근 30일)
daniel choudhry
daniel choudhry 2020년 11월 17일
댓글: daniel choudhry 2020년 11월 17일
I am having trouble setting this formula into my code and in my loop.
fs = 1000; % Hz
t = [1/fs:1/fs:length(COPNET_x)/fs];
n = length(COPNET_x);
%% Analyze data
COPNET_x = data_grf(:,11);
COPNET_z = data_grf(:,13);
GRFNET_x = data_grf(:,5);
GRFNET_y = data_grf(:,7);
Rx = max(COPNET_x)- min(COPNET_x); %sway range in AP
Rz = max(COPNET_z)-min(COPNET_z); % sway range in ML
for i = 1:n
Vel_AP = sum(abs(COPNET_x(i) - COPNET_x(i-1))/t)/n;
end

채택된 답변

David Hill
David Hill 2020년 11월 17일
No loop is necessary for the equation
sum(abs(diff(AP)).*fs)/length(AP);% it appears that 1/deltaT = fs
  댓글 수: 3
David Hill
David Hill 2020년 11월 17일
sum(sqrt(diff(AP).^2+diff(ML).^2).*fs)/length(AP);
%I am assuming this is what you want. Your equation seems to be missing some parentheses.
daniel choudhry
daniel choudhry 2020년 11월 17일
Thank you for your help!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by