unstack table with pre and post measurements
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Peter Perkins
2022-6-14
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.
回答(2 个)
Peter Perkins
2022-6-16
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!