File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11function subsA = spInd2SpSub(spA )
2- % SPIND2SPSUB Convert a sparse array's linear index into a matrix of subscripts.
2+ % SPIND2SPSUB Convert a sparse array's linear index into a matrix of subscripts.
33%
44% subsA = spInd2spSub(spA)
55%
66% By Andrew J. Milne, The MARCS Institute, Western Sydney University
7- %
7+ %
88% See also spSub2SpInd, spSub4Sp, ind2sub, sub2ind.
99
1010% Convert spA's linear index to subscripts
1111nDimA = numel(spA .Size );
12- cellSubA = cell(1 ,nDimA ); % create empty cell for next line
13- [cellSubA{: }] = ind2sub(spA .Size ,spA .Ind );
14- subsA = [cellSubA{: }];
12+ if nDimA == 1
13+ subsA = spA .Ind ;
14+ else
15+ cellSubA = cell(1 ,nDimA ); % create empty cell for next line
16+ [cellSubA{: }] = ind2sub(spA .Size ,spA .Ind );
17+ subsA = [cellSubA{: }];
18+ end
1519
1620end
1721
You can’t perform that action at this time.
0 commit comments