필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Matrix manipulation - smarter way to do this?

조회 수: 2 (최근 30일)
sas0701
sas0701 2013년 12월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
So,
1st column has trials from 1:300 but for each of the values there are multiple rows (this are samples in time - msecs)..
2nd column has conditions from 1:25.
See attached sample.txt
Each of the trials in column 1 is associated with a single value from column 2. Obviously multiple trials share the same conditions.
What I want is this:
1) Group conditions into eg. [2 5 7 10 ] or [1 4 5 6 7] etc.. I.e. any combination of conditions.
2) Group the corresponding trial data (Columns 3 to 10) separately. i.e. Column 3 from all the trials(1:300) that fall under Condition Group 1 should now become 1 matrix ordered in time.These should just stack on top of each other. I.e. same number of samples from each trial.
See attached Column5.txt (in this example trials 1 and 2 belonged to condition 5)
  댓글 수: 3
dpb
dpb 2013년 12월 4일
doc ismember
doc intersect % and friends
As said in response a day or two ago, look to the data object if have the Statistics Toolbox (never said yes/no)
doc accumarray
is useful with the above selection functions to build index vectors to fill arrays with results therefrom. Or, for single answers or for simply selecting subsets, look up 'logical addressing' in the documentation for how to address subsets of arrays based on conditional tests.
I suggest creating a much smaller sample of data as input and an example of the expected output and simply paste it into the window. 10 or even fewer lines should be plenty to illustrate the desire more simply than trying to parse the verbiage.
sas0701
sas0701 2013년 12월 5일
yes, I have statistics toolbox..did you see attached sample.txt(eg. sample input) and Column5.txt(eg. desired result)?

답변 (1개)

Walter Roberson
Walter Roberson 2013년 12월 4일
Build the vector G(K) such that K is a condition number and G(K) is the number of the condition group it is to be placed in. Then G(column2) tells you which matrix number to toss each line into.
for T = 1 : size(YourData,1)
Matrices{G(YourData(T,2))}(end+1,:) = YourData(T,3:end);
end
  댓글 수: 6
sas0701
sas0701 2013년 12월 5일
Hi,
when there are N repetitions of "1" in column 1, then the output derived from column 3 should be N wide?
Yes.
Results from column 3 are separate from results from column 4 and column 5 etc..
i.e. one output file (Column 3) is
80 70
70 60
....
Then the results from Column 4 are
391 391
391 391 ..
etc..
sas0701
sas0701 2013년 12월 6일
anyone?

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by