convert struct to cell array indexes Matlab -


how convert struct cell array indexes, have struct want convert cell array indexes respect to data & label. or possibly direct cell arrays according label , data avoid struct usage.

my code:

for ii = 1:13     jj = 1:numel(obj.r)         %r calc operatioiins     end     r=r(~cellfun('isempty',r)) ;     tdata(ii).data=r;     tdata(ii).label=cellfun(@(x) ['t' num2str(ii)] , num2cell(1:length(r))', 'uniformoutput', false);  end 

output:

  tdata(1).data  ans =       [10x3 double]     [10x3 double]     [10x3 double]     [10x3 double]     [10x3 double]     [10x3 double]     [10x3 double]  >> tdata(1).label  ans =       't1'     't1'     't1'     't1'     't1'     't1'     't1' 

edit 1:

possibly change following: actual output:

[10x3 double] [10x3 double] [ 8x3 double] [10x3 double] [10x3 double] [10x3 double] [10x3 double] 't1'          [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] 't2'          [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] [ 5x3 double] 't3'          

desired output:

[10x3 double] 't1'  [10x3 double] 't1'  [ 8x3 double] 't1'  [10x3 double] 't1'  [10x3 double] 't1'  [10x3 double] 't1'  [10x3 double] 't1'  

i'm not 100% on this, try adding end of for-loop:

tdatacellarray{ii} = {{tdata(ii).data}, {tdata(ii).label}} 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -