필터 지우기
필터 지우기

How to create a matrix from a vector using specified values

조회 수: 2 (최근 30일)
John Harry
John Harry 2015년 11월 3일
댓글: Geoff Hayes 2015년 11월 3일
I have a column of hip angle data from a treadmill walking trial (roughly 1 min) with a length of 12113 elements. I have identified heel strikes in a separate vector of data that has a length of 55 elements (55 heel strikes). I want to create a matrix where each column is hip angle data between successive elements of the heel strike vector (each column represents one stride). I have tried for loops and while loops, but nothing has worked.
I was able to create a single column of data representing one stride (using the commands below), but I need to get all 54 strides into a matrix. Do any of you have suggestions to how I can create the matrix?
i = 1;
LHIP(:,1) = LHIP_Angles(LHEE_Strikes(i):LHEE_Strikes(i+1));
Thanks in advance.

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 11월 3일
John - since it is unlikely that each stride has the same number of hip angles, you may want to use a cell array to store the data. Try the following
LHIP = cell(1,length(LHEE_Strikes)-1);
for k=1:length(LHEE_Strikes)-1
LHIP{k} = LHIP_Angles(LHEE_Strikes(k):LHEE_Strikes(k+1));
end
  댓글 수: 3
John Harry
John Harry 2015년 11월 3일
I wanted to let you know that I figured out how to normalize the cell array (created with your code, Geoff) and normalized it to 101 data points and then converted to a matrix.
Thanks again.
Geoff Hayes
Geoff Hayes 2015년 11월 3일
Awesome - glad to have been able to help, John!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by