MatrixBerryCore
cellstr2expression.m
Go to the documentation of this file.
1 function resStr = cellstr2expression(inpCMat,isMatrixStyle,isQuotingSkipped)
2 if nargin<3
3  isQuotingSkipped=false;
4 end
5 %
6 if ~ismatrix(inpCMat)
7  origSizeVec=size(inpCMat);
8  isReshaped=true;
9  inpCMat=reshape(inpCMat,origSizeVec(1),[]);
10 else
11  isReshaped=false;
12 end
13 %
14 if nargin<2
15  isMatrixStyle=false;
16 end
17 %
18 if ~(isMatrixStyle||isQuotingSkipped)
19  inpCMat=cellfun(@(x)sprintf('''%s''',strrep(x,'''','''''')),...
20  inpCMat,'UniformOutput',false);
21 end
22 lineList=strcat(mxberry.core.string.catcellstrwithsep(inpCMat,','),';');
23 resStr=[lineList{:}];
24 if isMatrixStyle
25  resStr=['[',resStr(1:end-1),']'];
26 else
27  resStr=['{',resStr(1:end-1),'}'];
28 end
29 if isReshaped
30  resStr=['reshape(',resStr,',',mat2str(origSizeVec),')'];
31 end
function cellstr2expression(in inpCMat, in isMatrixStyle, in isQuotingSkipped)
CELLSTR2EXPRESSION creates Matlab expression based on cell matrix of expressions corresponding to the...