How to find prefix and postfix in a recursive way
Afficher commentaires plus anciens
Hi! I have a array of strings: I want to find prefix and postfix; after find postfix I want to find prefix and postfix of it and so on.
Example
strings prefix postfix ---> prefix postfix ---> prefix postfix ---> prefix postfix
23414 2 3414 3 414 4 14 1 4
342(1) 3 42(1) 4 2(1) 2 (1) 1
34 3 4 4
231 2 31 3 1 1
I have tried to do it with this code:
semanticTrajCompact(1,4).TrajCompact=(semanticTrajCompact(1,4).TrajCompact(~cellfun('isempty',semanticTrajCompact(1,4).TrajCompact)));
semanticTrajCompact(1,4).TrajCompact=sort(semanticTrajCompact(1,4).TrajCompact);
for k=1:size(semanticTrajCompact(1,4).TrajCompact,1)
if ~isempty(semanticTrajCompact(1,4).TrajCompact{k,1})
if semanticTrajCompact(1,4).TrajCompact{k,1}(1)=='('
PrefixPostfix(1,4).prefix{k,1}=semanticTrajCompact(1,4).TrajCompact{k,1}(2:3);
PrefixPostfix(1,4).postfix{k,1}=semanticTrajCompact(1,4).TrajCompact{k,1}(5:end);
else
PrefixPostfix(1,4).prefix{k,1}=semanticTrajCompact(1,4).TrajCompact{k,1}(1);
PrefixPostfix(1,4).postfix{k,1}=semanticTrajCompact(1,4).TrajCompact{k,1}(2:end);
end
end
end
prefixTree(1,4).prefixTree(:,1)=semanticTrajCompact(1,4).TrajCompact;
prefixTree(1,4).prefixTree(:,2)=PrefixPostfix(1,4).prefix;
prefixTree(1,4).prefixTree(:,3)=PrefixPostfix(1,4).postfix;
After I have a problems to find prefix and postfix to leave from the result of
prefixTree(1,4).prefixTree(:,3)=PrefixPostfix(1,4).postfix;
Can you help me?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Report Generator Creation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!