Can you help me write this code please?

3 次查看(过去 30 天)
I have collected data from a force plate for Trial 7 to Trial 54. I have imported the data into Matlab and it looks like the picture shown below, all the data is in a cell and you have to double click the cell to access the data.
My code so far is this:
%% Import data
numfiles = 54; % number of excel files mydata=cell(numfiles,1); % defining size of mydata
for k = 7:numfiles % loop to import mutliple excel files
myfilename = sprintf('Trial %d', k); % define file name
mydata{k} = xlsread(myfilename); % import files into mydata
end
%% Define variables
a= 9.81 % acceleration fps = 250 % frames per second v = 0 % velocity
%%
numberOfZeros = numel(mydata(7,1)) - nnz(mydata);
I have to calculate jump height which is this equation: jumph = ((a*(t*t))/2)
I need to calculate the time the person was off the force plate which is done by counting how many zeros are in the third column of the data which is contained within each cell of the variable 'mydata'.
This is what the data looks like contained within each cell:
I don't know the code which allows me to access the data within the cell then count the number of zeros in the third column all within a loop so it carries the action out on every cell which contains all the data.
Please could someone give me help with this.

采纳的回答

A Jenkins
A Jenkins 2014-4-21
The syntax to access your cells is given on the top of the header bar: mydata{10,1}. Then you can treat it like any other array to get out the column you want.
for idx=1:length(mydata)
num_zeros=nnz(~mydata{idx,1}(:,3));
%other stuff to calculate time and height based on num_zeros
%jumph(idx,1)=((a*(t*t))/2)
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by