필터 지우기
필터 지우기

Reshape Cell to Matrix

조회 수: 1 (최근 30일)
Brian
Brian 2011년 12월 27일
So I'm having an issue adjusting this function to work with my actual dataset and it may be because I still don't understand the function quite right. (See answer to my original question here - http://www.mathworks.com/matlabcentral/answers/24527-reshape-cell-to-matrix)
My actual dataset format is as follows....
data = {'06/03/2011','00163T10'
'06/06/2011','00163T10'
'06/07/2011','00163T10'
'06/03/2011','ABCDEFGH'
'06/06/2011','ABCDEFGH'
'06/07/2011','ABCDEFGH'
'06/03/2011','ABCDWXYZ'
'06/06/2011','ABCDWXYZ'};
How would I go about using the arguments above with a dataset in this format. Ultimately, I am attempting to create a logical matrix of whether the ticker was in or out (1 or 0) for each given day using the accumarray function that Andrei began to help me with in the example posted above.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 12월 28일
try this cod (small corrected, typo)
d1 = datenum(data(:,1),'mm/dd/yyyy');
[a1,c1,c1] = unique(d1);
[a2,c2,c2] = unique(data(:,2));
out1 = accumarray([c1,c2],ones(numel(c1),1),[max(c1),max(c2)],@(x){x},{0});
out = [{NaN}, a2'; cellstr(datestr(a1,'mm/dd/yyyy')),out1];
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2011년 12월 28일
small corrected
Brian
Brian 2012년 4월 30일
Sorry for being so slow to respond to this. You answer worked brilliantly and I have been using it for a while now.
Thanks Andrei,
Brian

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by