Plotting a graph for step length

18 次查看(过去 30 天)
Hi. I have a data set that I need to plot against time. X=time. Y in this case is a step length recorded as '1' for right and '1' for left over the entire trial duration.
I need to plot this step length (left '1' to right '1' connecting line) over time.
I am not a Matlab user so need a guidance with this.
Thank you.
  8 个评论
Star Strider
Star Strider 2014-10-11
Plotting the steps (R & L) as functions of time is easy.
How do you define step length?
Kedar
Kedar 2014-10-11
编辑:Kedar 2014-10-11
I wouldn't say it is easy. This is possibly my first time to use Matlab. Left step length is defined as distance covered from left heel strike to right heel strike and similarly right side.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2014-10-12
编辑:Star Strider 2014-10-12
This is a bit much for an introduction to MATLAB.
The code begins by using the find function to determine the indices where ‘SoundLeft’ and ‘SoundRight’ are equal to 1, in ‘LSteps’ and ‘RSteps’ respectively. It then uses the index vectors to determine the times (denoted by the ‘Time’ vector) that the respective steps occur, in ‘LStepT’ and ‘RStepT’ respectively. Since you wanted the time differences between heel-strike for the left and right foot separately, all I then needed to do was the calculate the time differences between the successive heel strikes, and for that I used the diff function for each foot, in ‘LStepL’ and ‘RStepL’. Those are one element shorter than the corresponding ‘LStepT’ and ‘RStepT’, necessitating the (1:end-1) subscripts in the plot call. [The EDIT is this explanation, since you mentioned this was your first time using MATLAB.]
See if this does what you want:
[Time,Avatar_On,Sound_On,Sequenceindex,Condition,Treadmillpos,Treadmilltime,Treadmillspeed,SoundLeft,SoundRight,Avatar1pos,Avatar2pos,Avatar3pos,Action,AvatarSpeed,time,timespeed] = ImportAvatar0007('Avatar0007.txt',2, 33118);
LSteps = find(SoundLeft == 1);
RSteps = find(SoundRight == 1);
LStepT = Time(LSteps);
LStepL = diff(LStepT);
RStepT = Time(RSteps);
RStepL = diff(RStepT);
figure(1)
plot(LStepT(1:end-1), LStepL)
hold on
plot(RStepT(1:end-1), RStepL)
hold off
grid
xlabel('Time')
ylabel('Step Length (s)')
legend('Left', 'Right', 'Location','NE')
The code for the function MATLAB created to read your file (using textscan) is attached for you to use. My code requires it because I refer to the variables it creates.
  33 个评论
Star Strider
Star Strider 2014-11-26
That means that ‘info’ doesn’t exist in your workspace.
You need to go through your code to understand the reason. (If you intend to create it in an if block for instance, the if condition may not be met so the block never executes. I’m just guessing here.)
Star Strider
Star Strider 2014-11-28
You need to create ‘info’ and put something in it. (Empty variables can occasionally cause problems.)

请先登录,再进行评论。

更多回答(1 个)

Kedar
Kedar 2014-12-5
编辑:Kedar 2014-12-5
Hi,
How to convert .c3d to .mat file?
  1 个评论
Star Strider
Star Strider 2014-12-5
I’ve not a clue.
Also see Jan Simon’s File Exchange contribution C3D_VaxD2PC.
You would have to read the file into your MATLAB workspace, then save it as a .mat file.
That’s the best I can do.

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by