0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 function [ alfa ] = convertToSdp( alfa )
0015
0016 sdpIndex = 1;
0017
0018 for i = 1:length(alfa)
0019 target = char(alfa(i));
0020 if alfa(i) ~= 0 && isempty(strfind(target,'+')) && isempty(strfind(char(alfa(i)),'-')) && isempty(strfind(char(alfa(i)),'*'))
0021 names{sdpIndex} = target;
0022 sdpalfa{sdpIndex} = sdpvar(1);
0023 sdpIndex = sdpIndex + 1;
0024 end
0025 end
0026
0027 for i = 1:length(alfa)
0028 if ~isempty(strfind(char(alfa(i)),'+')) || ~isempty(strfind(char(alfa(i)),'-')) || ~isempty(strfind(char(alfa(i)),'*'))
0029 chr = strrep(char(alfa(i)),'+',' +');
0030 chr = strrep(chr,'-',' -');
0031 chr = strrep(chr,'*','* ');
0032 pieces = strsplit(' ',chr);
0033 for k=1:length(names)
0034 nameToCheck = names{k};
0035 found = false;
0036 index = 1;
0037 while ~found && index <= length(pieces)
0038 pieceToControl = char(pieces{index});
0039 if ~isempty(strfind(pieceToControl,nameToCheck))
0040 pieces{index} = sdpalfa{k};
0041 found = true;
0042 else
0043 index = index + 1;
0044 end
0045 end
0046 end
0047 result = '';
0048 for k = 1:length(pieces)
0049 if isempty(strfind(class(pieces{k}),'sdpvar'))
0050 result = strcat(result,char(pieces{k}));
0051 else
0052 string = cell2str(names{k});
0053 result = strcat(result,string);
0054 end
0055 end
0056 command = strcat('sdpalfa{',num2str(i),'}=',result,';');
0057 eval(command);
0058 end
0059
0060 end
0061
0062 return;