Plotting a graph for step length

18 visualizzazioni (ultimi 30 giorni)
Kedar
Kedar il 8 Ott 2014
Commentato: Star Strider il 5 Dic 2014
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 Commenti
Star Strider
Star Strider il 11 Ott 2014
Plotting the steps (R & L) as functions of time is easy.
How do you define step length?
Kedar
Kedar il 11 Ott 2014
Modificato: Kedar il 11 Ott 2014
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.

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 12 Ott 2014
Modificato: Star Strider il 12 Ott 2014
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 Commenti
Star Strider
Star Strider il 26 Nov 2014
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 il 28 Nov 2014
You need to create ‘info’ and put something in it. (Empty variables can occasionally cause problems.)

Accedi per commentare.

Più risposte (1)

Kedar
Kedar il 5 Dic 2014
Modificato: Kedar il 5 Dic 2014
Hi,
How to convert .c3d to .mat file?
  1 Commento
Star Strider
Star Strider il 5 Dic 2014
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.

Accedi per commentare.

Categorie

Scopri di più su Historical Contests in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by