unstack table with pre and post measurements

1 visualizzazione (ultimi 30 giorni)
Anna Pisz
Anna Pisz il 14 Giu 2022
Risposto: Peter Perkins il 16 Giu 2022
Hello,
I would like to orginize table so I have ie JumpHeight_pre, JumpHeight_post_1 etc.
I try to use unstack function
D=unstack(JH,["Name","UnweightingPhase","BrakingPhase","PropulsivePhase","RelativePropulsiveNetImpulse","SystemWeight","JumpHeight","JumpMomentum","CountermovementDepth","BrakingRFD","Stiffness","ForceAtMinDisplacement","Avg_BrakingForce","Avg_RelativeBrakingForce","PeakBrakingForce","PeakRelativeBrakingForce","Avg_PropulsiveForce","Avg_RelativePropulsiveForce","PeakPropulsiveForce","PeakRelativePropulsiveForce","UnweightingPhase","UnweightingPhase","BrakingPhase","BrakingPhase","PropulsivePhase","PropulsivePhase","FlightTime","TimeToTakeoff","BrakingNetImpulse","PropulsiveNetImpulse","PositiveImpulse","PositiveNetImpulse","ImpulseRatio","Avg_BrakingVelocity","PeakBrakingVelocity","Avg_PropulsiveVelocity","TakeoffVelocity","PeakVelocity","Avg_BrakingPower","Avg_RelativeBrakingPower","PeakBrakingPower","PeakRelativeBrakingPower","Avg_PropulsivePower","Avg_RelativePropulsivePower","PeakRelativePropulsivePower","PeakPropulsivePower","L_RPeakBrakingForce","LeftForceAtPeakBrakingForce","RightForceAtPeakBrakingForce","L_RAvg_BrakingForce","LeftAvg_BrakingForce","RightAvg_BrakingForce","L_RPeakPropulsiveForce","LeftForceAtPeakPropulsiveForce","RightForceAtPeakPropulsiveForce","L_RAvg_PropulsiveForce","LeftAvg_PropulsiveForce","RightAvg_PropulsiveForce","L_RAvg_BrakingRFD","LeftAvg_BrakingRFD","RightAvg_BrakingRFD","L_RBrakingImpulseIndex","L_RPropulsiveImpulseIndex","TimeToStabilization","LandingStiffness","PeakLandingForce","Avg_LandingForce","RelativePeakLandingForce","L_RPeakLandingForce","LeftForceAtPeakLandingForce","RightForceAtPeakLandingForce","L_RAvg_LandingForce","LeftAvg_LandingForce","RightAvg_LandingForce","L_RLandingImpulseIndex","RSI","mRSI","BrakingImpulse","RelativeBrakingImpulse","RelativeBrakingNetImpulse","PropulsiveImpulse","RelativePropulsiveImpulse"],'Phase')
however I recived table with a lot of missing values
I am not sure what to do to recieve immediately results in one row for one person.
Thank you for your help
  1 Commento
Peter Perkins
Peter Perkins il 14 Giu 2022
Anna, that command can't possibly be what you intend. You need to show a short example of what you are starting with, and what you want to end up with.

Accedi per commentare.

Risposte (2)

Anna Pisz
Anna Pisz il 15 Giu 2022
This is what I have
This is what I aim for.
I know that in R program function is call reshape and its aiming to change long data into wide... however I cannot make it in Matlab

Peter Perkins
Peter Perkins il 16 Giu 2022
unstack needs you to tell it three things:
1) which variables to unstack. It looks like you want SystemWeight, JumpHeight, ...
2) which (one) variable says where to put the unstacked values. It looks like you want Phase.
3) which rrows go together. often this is just "the remaining variable". It looks like you want Name.
>> Name = ["A";"A";"A";"B";"B";"B"];
>> Phase = ["one";"two";"three";"one";"two";"three"];
>> SystemWeight = rand(6,1);
>> JumpHeight = rand(6,1);
>> T = table(Name,Phase,SystemWeight,JumpHeight)
T =
6×4 table
Name Phase SystemWeight JumpHeight
____ _______ ____________ __________
"A" "one" 0.69483 0.76552
"A" "two" 0.3171 0.7952
"A" "three" 0.95022 0.18687
"B" "one" 0.034446 0.48976
"B" "two" 0.43874 0.44559
"B" "three" 0.38156 0.64631
>> unstack(T,["SystemWeight" "JumpHeight"],"Phase","GroupingVariables","Name")
ans =
2×7 table
Name SystemWeight_one SystemWeight_three SystemWeight_two JumpHeight_one JumpHeight_three JumpHeight_two
____ ________________ __________________ ________________ ______________ ________________ ______________
"A" 0.69483 0.95022 0.3171 0.76552 0.18687 0.7952
"B" 0.034446 0.38156 0.43874 0.48976 0.64631 0.44559

Categorie

Scopri di più su Tables in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by