-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_str_tags.m
46 lines (44 loc) · 1.96 KB
/
build_str_tags.m
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
37
38
39
40
41
42
43
44
45
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% WSINDy_PDE: generate strings for library terms
%%%%%%%%%%%%
%%%%%%%%%%%% Copyright 2020, All Rights Reserved
%%%%%%%%%%%% Code by Daniel A. Messenger
%%%%%%%%%%%% For Paper, "Weak SINDy for Partial Differential Equations"
%%%%%%%%%%%% by D. A. Messenger and D. M. Bortz
function [tags_pde,lib_list] = build_str_tags(lib_list,dim,n)
tags_pde = {};
ind = 1;
remove_inds = zeros(size(lib_list,1),1);
for j=1:size(lib_list)
tags = lib_list(j,:);
if dim == 2
str_pdx = [repelem('x',tags(end-1)),repelem('t',tags(end))];
elseif dim == 3
str_pdx = [repelem('x',tags(end-2)),repelem('y',tags(end-1)),repelem('t',tags(end))];
elseif dim == 4
str_pdx = [repelem('x',tags(end-3)),repelem('y',tags(end-2)),repelem('z',tags(end-1)),repelem('t',tags(end))];
end
if isreal(tags)
str_temp = '';
for nn=1:n-1
str_temp = strcat(str_temp,strcat(strrep(num2str(tags(nn)),' ',''),','));
end
str_temp = strcat(str_temp,strrep(num2str(tags(n)),' ',''));
tags_pde{ind} = ['u^{',str_temp,'}_{',str_pdx,'}'];
% tags_pde{ind} = ['u^{', strrep(num2str(tags(1:n)),' ',','),'}_{',str_pdx,'}'];
ind = ind+1;
else
ind_symb = imag(tags(1:n));
symb = sum(ind_symb);
if symb>0
tags_pde{ind} = ['cos(',num2str(abs(symb)),'u^{',strrep(num2str(ind_symb~=0),' ',','),'})_{',str_pdx,'}'];
ind = ind+1;
else
tags_pde{ind} = ['sin(',num2str(abs(symb)),'u^{',strrep(num2str(ind_symb~=0),' ',','),'})_{',str_pdx,'}'];
ind = ind+1;
end
end
% end
end
lib_list = lib_list(~remove_inds,:);
end