Can you help me write this code please?
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
A Jenkins
on 21 Apr 2014
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 Comments
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!