Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

jump height data

Status
Not open for further replies.

Kat1990

Materials
Mar 5, 2014
2
Hi everyone,

I am fairly new to matlab and having some troubles with the code I need to write to interrogate some data. I was wondering if you could help. So far I have this code:

clear all; % clears all variables from your workspace
close all; % closes all figure windows
clc; % clears command window
%%=============================================
%%define number of trials and subjects
%%=============================================
njump=81;
nsbj=6;

%%
%%==============================================
%%defining size of cell that will be created
%%==============================================
data=cell(njump,1);

%%
%%==============================================
%%defining gravity and frame rate per second (fps)
%%==============================================
fps=0.001; %frames per second
g=-9.81; %acceleration

%%
%%==============================================
%%read in excel data in CSV format
%%===============================================

for i=1:njump;
x=sprintf('Trial%02d.csv',i),sprintf('Trial%02d',i),'A1:E7000';;% jump data
data{i}=xlsread(x,'A1:E7000');


%%===============================================
%%defining total no. of frames and time of flight
%tnf=total number of frames equal to zero
%n = nnz(X) returns the number of nonzero elements in matrix X.
%%===============================================
% myMax(i) = nanmax(data{i}:),5));
% vals = find(data{i}:),5) > (myMax(i) - 10));
% pointsInAir = numel(vals,i);
tnf(i,1) = size(data{i,1},1) - nnz(data{i,1}:),5)); %number of zeros
tof(i)=tnf(i)*fps; %Time of flight is equal to this
jh(i,1)=(-g*(tof(i).^2)/8); %defining jump height



%%=================================================
%%to find average power first use "find" function to find the first zero in
%%Fz, have the cell referenced
%%then use nanmean for average power(av_pwr)
%%use nanmin for peak power (peak_pwr)
%%=================================================

ref(i) = find(data{i,1}==0,'first');
ref(i) = ref(1);
peak_pwr(i) = nanmin (data{i,1}(1:ref,5)); %preak power in coloumn E1 in all data with reference to cell found
av_pwr(i,1)=nanmean(data{i,1}(1:ref,5));%average power in coloumn E1 in all data with reference to cell found

end





the last part of code starting with "ref" does not work. I am trying to find the last zero in an Fz column to use as a reference point so that I can use all the data before that in the Fz column (which is column number 5)to calculate peak and average power from all 81 trials.

can anyone help me to solve this?

thanks.
 
Replies continue below

Recommended for you

This looks like one of those classic vectorization problems that get posted to the comp.soft-sys.matlab USENET newsgroup.

If you post a sample (simple) dataset, the rules and an expected result (to that newsgroup and here), you may find the answer is in a single line of Matlab.

- Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor