-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdynamicCellExample.m
More file actions
36 lines (29 loc) · 1008 Bytes
/
dynamicCellExample.m
File metadata and controls
36 lines (29 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% DYNAMICCELLEXAMPLE Dynamically creating a nested cell structure (unfinished/deprecated)
clear; close all
% User input character vector:
str = 'stores{2}.name';
% Create a 2xN cell array {index type ; field/index} from that char vector:
tkn = regexp(['.',str],'(\W)(\w+)','tokens'); % assumes the first part is always a field.
tkn = vertcat(tkn{:}).';
tkn(1,:) = strrep(strrep(tkn(1,:),'{','{}'),'(','()');
% Convert linear indices to numeric:
vec = str2double(tkn(2,:));
idx = ~isnan(vec);
tkn(2,idx) = num2cell(num2cell(vec(idx)));
% Create indexing structure from the cell array:
sbs = substruct(tkn{:});
val = subsref(config,sbs)
%%
K = cell(1,2); K{2} = cell(1,2);
S.type = '{}';
S.subs = {2};
val = subsref(K,S)
%%
a2 = {{'asdf',{'asdf','asdf',{'asdf'},{'asdf'},{'asdf',{'asdf'}},'asdf'},{'asdf',{'asdf'},{{'asdf'}}}},'asdf'}
while any(cellfun(@iscell,a2))
a2 = [a2{cellfun(@iscell,a2)} a2(~cellfun(@iscell,a2))];
end
%%
%{
How to apply a tree-based indexing scheme for a triangulation?
%}